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

Save/load comparison objects with pickle #2013

Merged
merged 2 commits into from
Sep 22, 2023
Merged
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
15 changes: 15 additions & 0 deletions src/spikeinterface/comparison/multicomparisons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path
import json
import pickle
import warnings

import numpy as np

Expand Down Expand Up @@ -180,6 +181,13 @@ def get_agreement_sorting(self, minimum_agreement_count=1, minimum_agreement_cou
return sorting

def save_to_folder(self, save_folder):
warnings.warn(
"save_to_folder() is deprecated. "
"You should save and load the multi sorting comparison object using pickle."
"\n>>> pickle.dump(mcmp, open('mcmp.pkl', 'wb')))))\n>>> mcmp_loaded = pickle.load(open('mcmp.pkl', 'rb'))",
DeprecationWarning,
stacklevel=2,
)
for sorting in self.object_list:
assert (
sorting.check_if_json_serializable()
Expand All @@ -205,6 +213,13 @@ def save_to_folder(self, save_folder):

@staticmethod
def load_from_folder(folder_path):
warnings.warn(
"load_from_folder() is deprecated. "
"You should save and load the multi sorting comparison object using pickle."
"\n>>> pickle.dump(mcmp, open('mcmp.pkl', 'wb')))))\n>>> mcmp_loaded = pickle.load(open('mcmp.pkl', 'rb'))",
DeprecationWarning,
stacklevel=2,
)
folder_path = Path(folder_path)
with (folder_path / "kwargs.json").open() as f:
kwargs = json.load(f)
Expand Down