Skip to content

Commit

Permalink
CI - fix flaky type check failure in cirq.vis.heatmap (#6750)
Browse files Browse the repository at this point in the history
Avoid `Incompatible types in assignment` error by providing explicit
cast of the value returned from `get_facecolor()`.

The failure is flaky and more likely to happen if run without mypy cache
This fix was verified using:

    for i in {1..50}; do check/mypy --cache-dir=/dev/null || break; done
  • Loading branch information
pavoljuhas authored Oct 3, 2024
1 parent 95f6a3f commit 55b2c30
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cirq-core/cirq/vis/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
SupportsFloat,
Tuple,
Union,
TYPE_CHECKING,
)

import matplotlib as mpl
Expand All @@ -40,8 +39,6 @@
from cirq.devices import grid_qubit
from cirq.vis import vis_utils

if TYPE_CHECKING:
from numpy.typing import ArrayLike

QubitTuple = Tuple[grid_qubit.GridQubit, ...]

Expand Down Expand Up @@ -240,8 +237,8 @@ def _write_annotations(
ax: plt.Axes,
) -> None:
"""Writes annotations to the center of cells. Internal."""
facecolor: ArrayLike
for (center, annotation), facecolor in zip(centers_and_annot, collection.get_facecolor()):
face_colors = cast(np.ndarray, collection.get_facecolor())
for (center, annotation), facecolor in zip(centers_and_annot, face_colors):
# Calculate the center of the cell, assuming that it is a square
# centered at (x=col, y=row).
if not annotation:
Expand Down

0 comments on commit 55b2c30

Please sign in to comment.