Skip to content

Commit

Permalink
Remove unecessary references to UserDict self.data and better documen…
Browse files Browse the repository at this point in the history
…t UserDict.
  • Loading branch information
JoeZiminski committed Oct 3, 2023
1 parent 534c7f0 commit a9a4c8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 6 additions & 3 deletions spikewrap/data_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ class BaseUserDict(UserDict):
folder, allowing use of this class for
preprocessing and sorting.
Base UserDict that implements the
keys(), values() and items() convenience functions."""
This class inhereits from UserDict, which allows us to define
a dictionary-like object with additional methods. This class can
be accessed like a dict e.g.g `self[key]`. Under the hood, the
dictionary is stored in `self.data.`. Base UserDict that implements
the keys(), values() and items() convenience functions.
"""

base_path: Path
sub_name: str
sessions_and_runs: Dict[str, List[str]]

def __post_init__(self) -> None:
self.data: Dict = {}
self.base_path = Path(self.base_path)
self.check_run_names_are_formatted_as_list()

Expand Down
2 changes: 1 addition & 1 deletion spikewrap/data_classes/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __post_init__(self) -> None:
self.sync: Dict = {}

for ses_name, run_name in self.preprocessing_sessions_and_runs():
utils.update(self.data, ses_name, run_name, {"0-raw": None})
utils.update(self, ses_name, run_name, {"0-raw": None})
utils.update(self.sync, ses_name, run_name, None)

def set_pp_steps(self, pp_steps: Dict) -> None:
Expand Down
6 changes: 2 additions & 4 deletions spikewrap/data_classes/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ def load_preprocessed_binary(self) -> None:
concat_run_recordings = []
for ses_name in recordings.keys():
concat_run_recordings.append(self._concatenate_runs(ses_name, recordings))
self.data[self.concat_ses_name()] = concatenate_recordings(
concat_run_recordings
)
self[self.concat_ses_name()] = concatenate_recordings(concat_run_recordings)

def get_sorting_sessions_and_runs(self): # TODO: type
return [(self.concat_ses_name(), None)]
Expand Down Expand Up @@ -404,7 +402,7 @@ def load_preprocessed_binary(self) -> None:
for ses_name in self.sessions_and_runs.keys():
concat_recording = self._concatenate_runs(ses_name, recordings)
utils.update(
self.data, ses_name, self.concat_run_name(ses_name), concat_recording
self, ses_name, self.concat_run_name(ses_name), concat_recording
)

def get_sorting_sessions_and_runs(self): # TODO: type
Expand Down

0 comments on commit a9a4c8c

Please sign in to comment.