Skip to content

Commit

Permalink
improve analyzer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgarcia committed May 23, 2024
1 parent 9f71562 commit 586fab6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/spikeinterface/core/sparsity.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ def __repr__(self):
txt = f"ChannelSparsity - units: {self.num_units} - channels: {self.num_channels} - density, P(x=1): {density:0.2f}"
return txt

def __eq__(self, other):
return (
isinstance(other, ChannelSparsity)
and np.array_equal(self.channel_ids, other.channel_ids)
and np.array_equal(self.unit_ids, other.unit_ids)
and np.array_equal(self.mask, other.mask)
)

@property
def unit_id_to_channel_ids(self):
if self._unit_id_to_channel_ids is None:
Expand Down
5 changes: 5 additions & 0 deletions src/spikeinterface/core/tests/test_sortinganalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,15 @@ def _check_sorting_analyzers(sorting_analyzer, original_sorting, cache_folder):

data = sorting_analyzer2.get_extension("dummy").data
assert "result_one" in data
assert isinstance(data["result_one"], str)
assert isinstance(data["result_two"], np.ndarray)
assert data["result_two"].size == original_sorting.to_spike_vector().size
assert np.array_equal(data["result_two"], sorting_analyzer.get_extension("dummy").data["result_two"])

assert sorting_analyzer2.return_scaled == sorting_analyzer.return_scaled

assert sorting_analyzer2.sparsity == sorting_analyzer.sparsity

# select unit_ids to several format
for format in ("memory", "binary_folder", "zarr"):
if format != "memory":
Expand Down

0 comments on commit 586fab6

Please sign in to comment.