Skip to content

Commit

Permalink
mypy 4/n
Browse files Browse the repository at this point in the history
  • Loading branch information
timtreis committed Oct 23, 2024
1 parent 7a2193d commit fb87e1f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/squidpy/gr/_nhood.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def _interaction_matrix(
cur_row = cats[i]
cur_indices = indices_list[i]
cur_data = data_list[i]
for j, val in zip(cur_indices, cur_data, strict=False):
for j, val in zip(cur_indices, cur_data): # noqa: B905
cur_col = cats[j]
output[cur_row, cur_col] += val
return output
Expand Down
6 changes: 3 additions & 3 deletions src/squidpy/pl/_spatial_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,16 @@ def _decorate_axs(
def _map_color_seg(
seg: NDArrayA,
cell_id: NDArrayA,
color_vector: NDArrayA | pd.Series[CategoricalDtype],
color_source_vector: pd.Series[CategoricalDtype],
color_vector: NDArrayA | pd.Categorical,
color_source_vector: pd.Categorical,
cmap_params: CmapParams,
seg_erosionpx: int | None = None,
seg_boundaries: bool = False,
na_color: str | tuple[float, ...] = (0, 0, 0, 0),
) -> NDArrayA:
cell_id = np.array(cell_id)

if isinstance(color_vector, pd.Series) and isinstance(color_vector.dtype, pd.CategoricalDtype):
if isinstance(color_vector, pd.Categorical):
if isinstance(na_color, tuple) and len(na_color) == 4 and np.any(color_source_vector.isna()):
cell_id[color_source_vector.isna()] = 0
val_im: NDArrayA = map_array(seg, cell_id, color_vector.codes + 1)
Expand Down
2 changes: 1 addition & 1 deletion tests/image/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def test_spot_crops_as_array_return_obs(
if not as_array:
assert Key.img.obs in crop.data.attrs

if as_array:
if as_array is True: # cannot do 'if as_array' because the string would also be true
assert isinstance(crop, dict), type(crop)
for key in cont:
assert key in crop
Expand Down

0 comments on commit fb87e1f

Please sign in to comment.