Skip to content

Commit 32af8a3

Browse files
hawkinspcopybara-github
authored andcommitted
[numpy] Replace uses of np.in1d with np.isin(...).ravel().
np.in1d is removed in NumPy 2.4. PiperOrigin-RevId: 839920619
1 parent 004313c commit 32af8a3

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

ffn/inference/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def clear_dust(data: np.ndarray, min_size: int = 10):
3232
"""
3333
ids, sizes = np.unique(data, return_counts=True)
3434
small = ids[sizes < min_size]
35-
small_mask = np.in1d(data.flat, small).reshape(data.shape)
35+
small_mask = np.isin(data.flat, small).ravel().reshape(data.shape)
3636
data[small_mask] = 0
3737
return data
3838

ffn/inference/storage.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,7 @@ def build_mask(masks, corner, subvol_size, mask_volume_map=None,
391391
src_corner, channel_mask, corner, subvol_size)
392392

393393
if chan_config.values:
394-
bool_mask = np.in1d(channel_mask,
395-
chan_config.values).reshape(channel_mask.shape)
394+
bool_mask = np.isin(channel_mask, chan_config.values).ravel().reshape(channel_mask.shape)
396395
else:
397396
bool_mask = ((channel_mask >= chan_config.min_value) &
398397
(channel_mask <= chan_config.max_value))

0 commit comments

Comments
 (0)