Skip to content

Commit 63a66f5

Browse files
authored
Merge pull request #3455 from samuelgarcia/fix_warning_qm
Avoid warnings in sorting analyzer
2 parents a09dd57 + b3a397c commit 63a66f5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,8 @@ def load_data(self):
19761976
continue
19771977
ext_data_name = ext_data_file.stem
19781978
if ext_data_file.suffix == ".json":
1979-
ext_data = json.load(ext_data_file.open("r"))
1979+
with ext_data_file.open("r") as f:
1980+
ext_data = json.load(f)
19801981
elif ext_data_file.suffix == ".npy":
19811982
# The lazy loading of an extension is complicated because if we compute again
19821983
# and have a link to the old buffer on windows then it fails
@@ -1988,7 +1989,8 @@ def load_data(self):
19881989

19891990
ext_data = pd.read_csv(ext_data_file, index_col=0)
19901991
elif ext_data_file.suffix == ".pkl":
1991-
ext_data = pickle.load(ext_data_file.open("rb"))
1992+
with ext_data_file.open("rb") as f:
1993+
ext_data = pickle.load(f)
19921994
else:
19931995
continue
19941996
self.data[ext_data_name] = ext_data

src/spikeinterface/qualitymetrics/quality_metric_calculator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def _run(self, verbose=False, **job_kwargs):
234234
)
235235

236236
existing_metrics = []
237-
qm_extension = self.sorting_analyzer.get_extension("quality_metrics")
237+
# here we get in the loaded via the dict only (to avoid full loading from disk after params reset)
238+
qm_extension = self.sorting_analyzer.extensions.get("quality_metrics", None)
238239
if (
239240
delete_existing_metrics is False
240241
and qm_extension is not None

0 commit comments

Comments
 (0)