Skip to content

Commit 91c2a0d

Browse files
committed
Add save argument to set_unit_property
1 parent 70dace5 commit 91c2a0d

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/spikeinterface/core/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ def set_property(
231231
ids : list/np.array, default: None
232232
List of subset of ids to set the values, default: None
233233
if None which is the default all the ids are set or changed
234-
missing_value : object, default: None
234+
missing_value : Any, default: None
235235
In case the property is set on a subset of values ("ids" not None),
236-
it specifies the how the missing values should be filled.
237-
The missing_value has to be specified for types int and unsigned int.
236+
This argument specifies how to fill missing values.
237+
The `missing_value` is required for types int and unsigned int.
238238
"""
239239

240240
if values is None:

src/spikeinterface/core/sortinganalyzer.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ class SortingAnalyzer:
223223

224224
def __init__(
225225
self,
226-
sorting=None,
227-
recording=None,
228-
rec_attributes=None,
229-
format=None,
230-
sparsity=None,
231-
return_scaled=True,
232-
backend_options=None,
226+
sorting: BaseSorting,
227+
recording: BaseRecording | None = None,
228+
rec_attributes: dict | None = None,
229+
format: str | None = None,
230+
sparsity: ChannelSparsity | None = None,
231+
return_scaled: bool = True,
232+
backend_options: dict | None = None,
233233
):
234234
# very fast init because checks are done in load and create
235235
self.sorting = sorting
@@ -239,6 +239,7 @@ def __init__(
239239
self.format = format
240240
self.sparsity = sparsity
241241
self.return_scaled = return_scaled
242+
self.folder: str | Path | None = None
242243

243244
# this is used to store temporary recording
244245
self._temporary_recording = None
@@ -748,6 +749,7 @@ def set_unit_property(
748749
values: list | np.ndarray | tuple,
749750
ids: list | np.ndarray | tuple | None = None,
750751
missing_value: Any = None,
752+
save: bool = True,
751753
) -> None:
752754
"""
753755
Set property vector for unit ids.
@@ -767,11 +769,13 @@ def set_unit_property(
767769
if None all the ids are set or changed
768770
missing_value : Any, default: None
769771
In case the property is set on a subset of values ("ids" not None),
770-
This argument specifies how to fill missing values
772+
This argument specifies how to fill missing values.
771773
The `missing_value` is required for types int and unsigned int.
774+
save : bool, default: True
775+
If True, the property is saved to the backend if possible.
772776
"""
773777
self.sorting.set_property(key, values, ids=ids, missing_value=missing_value)
774-
if not self.is_read_only():
778+
if not self.is_read_only() and save:
775779
if self.format == "binary_folder":
776780
np.save(self.folder / "sorting" / "properties" / f"{key}.npy", self.sorting.get_property(key))
777781
elif self.format == "zarr":

0 commit comments

Comments
 (0)