Skip to content

Commit 38df520

Browse files
committed
Consider already chopped wires during propagation; fix bug in optimization
1 parent 95e859b commit 38df520

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/classy_blocks/items/wires/manager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,15 @@ def propagate_gradings(self) -> None:
6666
raise UndefinedGradingsError("Can't propagate: no defined wires")
6767

6868
for wire in self.wires:
69-
wire.grading = defined.grading.copy(wire.length, False)
70-
wire.copy_to_coincidents()
69+
# only copy to wires that have no defined coincident wires
70+
# TODO: test, rethink, refactor, reimplement
71+
for coincident in wire.coincidents:
72+
if coincident.is_defined:
73+
coincident.copy_to_coincidents()
74+
break
75+
else:
76+
wire.grading = defined.grading.copy(wire.length, False)
77+
wire.copy_to_coincidents()
7178

7279
@property
7380
def count(self):

src/classy_blocks/optimize/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def fquality(params):
5454
reporter.junction_final = junction.quality
5555
reporter.grid_final = self.grid.quality
5656

57-
if reporter.improvement <= 0:
57+
if np.isnan(reporter.improvement) or reporter.improvement <= 0:
5858
reporter.rollback()
5959

6060
clamp.update_params(initial_params)

0 commit comments

Comments
 (0)