Skip to content

Commit

Permalink
Fix Python mismatch display code.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgevans committed Jun 27, 2024
1 parent bd3f297 commit 0c34a90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.15.1

- Fix Python mismatch display code (some mismatches were not shown).

# 0.15.0

- Start order tracking at 1 (0 is a site that was never filled).
Expand Down
16 changes: 8 additions & 8 deletions py-rgrow/rgrow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
System,
State,
EvolveBounds,
FFSStateRef
FFSStateRef,
)
import attrs
import attr
Expand Down Expand Up @@ -56,7 +56,9 @@ def _system_name_canvas(self: System, state: State | FFSStateRef) -> np.ndarray:
System.name_canvas = _system_name_canvas # type: ignore


def _system_color_canvas(self: System, state: State | np.ndarray | FFSStateRef) -> np.ndarray:
def _system_color_canvas(
self: System, state: State | np.ndarray | FFSStateRef
) -> np.ndarray:
"""Returns the current canvas for state, as an array of tile colors."""

if isinstance(state, (State, FFSStateRef)):
Expand Down Expand Up @@ -170,11 +172,9 @@ def _system_plot_canvas(
mml = sys.calc_mismatch_locations(state)
for i, j in zip(*mml.nonzero()):
d = mml[i, j]
if d > 2:
# will have already been marked by the other side
# mismatches are designated by 8*N+4*E+2*S+1*W
continue
elif d == 1: # W
# We check only 0b1 (west) and 0b10 (south), as 0b100 (east) and 0b1000 (north)
# will be covered by the tile on the other side of the mismatch.
if int(d) & 1: # W
ax.add_patch(
plt.Rectangle(
(j - 0.75, i - 0.25),
Expand All @@ -186,7 +186,7 @@ def _system_plot_canvas(
linewidth=0,
)
)
elif d == 2: # S
if int(d) & 2: # S
ax.add_patch(
plt.Rectangle(
(j - 0.25, i + 0.25),
Expand Down

0 comments on commit 0c34a90

Please sign in to comment.