Skip to content

Commit

Permalink
Merge pull request #2503 from neutrinoceros/numpy2_depr
Browse files Browse the repository at this point in the history
MNT: replace `np.in1d` (deprecated) with `np.isin`
  • Loading branch information
astrofrog authored Jul 15, 2024
2 parents c0a8794 + 5b9472d commit 6cb7094
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions glue/core/joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_mask_with_key_joins(data, key_joins, subset_state, view=None):

key_left = data.get_data(cid1[0], view=view)
key_right = other.get_data(cid2[0], view=mask_right)
mask = np.in1d(key_left.ravel(), key_right.ravel())
mask = np.isin(key_left.ravel(), key_right.ravel())

return mask.reshape(key_left.shape)

Expand All @@ -72,7 +72,7 @@ def get_mask_with_key_joins(data, key_joins, subset_state, view=None):
key_left_all = concatenate_arrays(*key_left_all)
key_right_all = concatenate_arrays(*key_right_all)

mask = np.in1d(key_left_all, key_right_all)
mask = np.isin(key_left_all, key_right_all)

return mask.reshape(data.get_data(cid1_i, view=view).shape)

Expand All @@ -82,7 +82,7 @@ def get_mask_with_key_joins(data, key_joins, subset_state, view=None):
mask = np.zeros_like(key_left, dtype=bool)
for cid2_i in cid2:
key_right = other.get_data(cid2_i, view=mask_right).ravel()
mask |= np.in1d(key_left, key_right)
mask |= np.isin(key_left, key_right)

return mask.reshape(data.get_data(cid1[0], view=view).shape)

Expand All @@ -92,7 +92,7 @@ def get_mask_with_key_joins(data, key_joins, subset_state, view=None):
mask = np.zeros_like(data.get_data(cid1[0], view=view).ravel(), dtype=bool)
for cid1_i in cid1:
key_left = data.get_data(cid1_i, view=view).ravel()
mask |= np.in1d(key_left, key_right)
mask |= np.isin(key_left, key_right)

return mask.reshape(data.get_data(cid1[0], view=view).shape)

Expand Down
2 changes: 1 addition & 1 deletion glue/core/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ def to_mask(self, data, view=None):
vals = data[self._att, view]
if isinstance(vals, categorical_ndarray):
vals = vals.codes
result = np.in1d(vals.ravel(), self._categories)
result = np.isin(vals.ravel(), self._categories)
return result.reshape(vals.shape)

def copy(self):
Expand Down

0 comments on commit 6cb7094

Please sign in to comment.