Skip to content

Commit

Permalink
Merge branch 'main' into overwrite_motion
Browse files Browse the repository at this point in the history
  • Loading branch information
yger authored Jul 1, 2024
2 parents 6843070 + f8b638e commit cfb971e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/spikeinterface/core/core_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def default(self, obj):
if isinstance(obj, BaseExtractor):
return obj.to_dict()

if isinstance(obj, Path):
return str(obj)

if isinstance(obj, Motion):
return obj.to_dict()

Expand Down
29 changes: 21 additions & 8 deletions src/spikeinterface/core/tests/test_jsonification.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
from spikeinterface.core.core_tools import SIJsonEncoder
from spikeinterface.core.generate import generate_recording, generate_sorting


@pytest.fixture(scope="module")
def numpy_generated_recording():
recording = generate_recording()
return recording
from pathlib import Path


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -124,8 +120,25 @@ def test_numpy_dtype_alises_encoding():
json.dumps(np.float32, cls=SIJsonEncoder)


def test_recording_encoding(numpy_generated_recording):
recording = numpy_generated_recording
def test_path_encoding(tmp_path):

temporary_path = tmp_path / "a_path_for_this_test"

json.dumps(temporary_path, cls=SIJsonEncoder)


def test_path_as_annotation(tmp_path):
temporary_path = tmp_path / "a_path_for_this_test"

recording = generate_recording()
recording.annotate(path=temporary_path)

json.dumps(recording, cls=SIJsonEncoder)


def test_recording_encoding():
recording = generate_recording()

json.dumps(recording, cls=SIJsonEncoder)


Expand Down Expand Up @@ -200,4 +213,4 @@ def test_encoding_numpy_scalars_within_nested_extractors_dict(nested_extractor_d

if __name__ == "__main__":
nested_extractor = nested_extractor()
test_encoding_numpy_scalars_within_nested_extractors(nested_extractor_)
test_encoding_numpy_scalars_within_nested_extractors(nested_extractor)

0 comments on commit cfb971e

Please sign in to comment.