Skip to content

Commit

Permalink
Merge pull request #2013 from alejoe91/save-load-comparison
Browse files Browse the repository at this point in the history
Save/load comparison objects with pickle
  • Loading branch information
samuelgarcia authored Sep 22, 2023
2 parents d78cb07 + 3d2f41c commit 37463ac
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 37463ac

Please sign in to comment.