Skip to content

Commit

Permalink
Fix Python mismatch display code.
Browse files Browse the repository at this point in the history
(cherry picked from commit 0c34a90)
  • Loading branch information
cgevans committed Jun 27, 2024
1 parent 9baa8d6 commit 3530f7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Improved FFS polars dataframe output creation:
- configs now include tracking information, if present.
- configs no longer breaks if keep_configs is false (shows last configurations)
- Fix Python mismatch display code (some mismatches were not shown).

# 0.15.0

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 3530f7c

Please sign in to comment.