Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change np.in1d into np.isin as np.in1d will be deprecated with new versions of NumPy #40

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phylib/io/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _spikes_in_clusters(spike_clusters, clusters):
"""Return the ids of all spikes belonging to the specified clusters."""
if len(spike_clusters) == 0 or len(clusters) == 0:
return np.array([], dtype=int)
return np.nonzero(np.in1d(spike_clusters, clusters))[0]
return np.nonzero(np.isin(spike_clusters, clusters))[0]


def _spikes_per_cluster(spike_clusters, spike_ids=None):
Expand Down
4 changes: 2 additions & 2 deletions phylib/io/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def from_sparse(data, cols, channel_ids):
# NOTE: we ensure here that `col` contains integers.
c = cols.flatten().astype(np.int32)
# Remove columns that do not belong to the specified channels.
c[~np.in1d(c, channel_ids)] = -1
assert np.all(np.in1d(c, np.r_[channel_ids, -1]))
c[~np.isin(c, channel_ids)] = -1
assert np.all(np.isin(c, np.r_[channel_ids, -1]))
# Convert column indices to relative indices given the specified
# channel_ids.
cols_loc = _index_of(c, np.r_[channel_ids, -1]).reshape(cols.shape)
Expand Down
2 changes: 1 addition & 1 deletion phylib/io/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def test_spikes_in_clusters():
assert np.all(spike_clusters[_spikes_in_clusters(spike_clusters, [i])] == i)

clusters = [1, 2, 3]
assert np.all(np.in1d(
assert np.all(np.isin(
spike_clusters[_spikes_in_clusters(spike_clusters, clusters)], clusters))


Expand Down
2 changes: 1 addition & 1 deletion phylib/stats/tests/test_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_sorted_main_channels(masks):
mean_masks = mean(masks)
channels = get_sorted_main_channels(mean_masks,
get_unmasked_channels(mean_masks))
assert np.all(np.in1d(channels, [5, 7]))
assert np.all(np.isin(channels, [5, 7]))


def test_waveform_amplitude(masks, waveforms):
Expand Down