Skip to content

Commit

Permalink
rename to check_if_memory_serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgarcia committed Sep 27, 2023
1 parent 9d3dcea commit 7329927
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/spikeinterface/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,7 @@ def check_serializablility(self, type):
return False
return self._serializablility[type]

def check_if_dumpable(self):
warnings.warn("check_if_dumpable() is replace by is_memory_serializable()", DeprecationWarning, stacklevel=2)
return self.check_serializablility("memory")

def is_memory_serializable(self):
def check_if_memory_serializable(self):
"""
Check if the object is serializable to memory with pickle, including nested objects.
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/core/job_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def ensure_n_jobs(recording, n_jobs=1):
print(f"Python {sys.version} does not support parallel processing")
n_jobs = 1

if not recording.is_memory_serializable():
if not recording.check_if_memory_serializable():
if n_jobs != 1:
raise RuntimeError(
"Recording is not dumpable and can't be processed in parallel. "
Expand Down
8 changes: 4 additions & 4 deletions src/spikeinterface/core/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def make_nested_extractors(extractor):
)


def test_is_memory_serializable():
def test_check_if_memory_serializable():
test_extractor = generate_recording(seed=0, durations=[2])

# make a list of dumpable objects
extractors_dumpable = make_nested_extractors(test_extractor)
for extractor in extractors_dumpable:
assert extractor.is_memory_serializable()
assert extractor.check_if_memory_serializable()

# make not dumpable
test_extractor._serializablility["memory"] = False
extractors_not_dumpable = make_nested_extractors(test_extractor)
for extractor in extractors_not_dumpable:
assert not extractor.is_memory_serializable()
assert not extractor.check_if_memory_serializable()


def test_check_if_serializable():
Expand All @@ -66,5 +66,5 @@ def test_check_if_serializable():


if __name__ == "__main__":
test_is_memory_serializable()
test_check_if_memory_serializable()
test_check_if_serializable()
2 changes: 1 addition & 1 deletion src/spikeinterface/postprocessing/spike_amplitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _run(self, **job_kwargs):
n_jobs = ensure_n_jobs(recording, job_kwargs.get("n_jobs", None))
if n_jobs != 1:
# TODO: avoid dumping sorting and use spike vector and peak pipeline instead
assert sorting.is_memory_serializable(), (
assert sorting.check_if_memory_serializable(), (
"The sorting object is not dumpable and cannot be processed in parallel. You can use the "
"`sorting.save()` function to make it dumpable"
)
Expand Down

0 comments on commit 7329927

Please sign in to comment.