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. (#127)
  • Loading branch information
JoeZiminski authored Nov 16, 2023
1 parent 43785d5 commit 392028e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
10 changes: 7 additions & 3 deletions spikewrap/data_classes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ 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. `self[key]`. Under the hood, the
dictionary is stored in `self.data`. When inheriting UserDict
it is required to implement 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
3 changes: 2 additions & 1 deletion spikewrap/data_classes/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __post_init__(self) -> None:
self.sync: Dict = {}

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

self.update_two_layer_dict(self, ses_name, run_name, {"0-raw": None})
self.update_two_layer_dict(self.sync, ses_name, run_name, None)

def set_pp_steps(self, pp_steps: Dict) -> None:
Expand Down
8 changes: 3 additions & 5 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 @@ -403,9 +401,9 @@ def load_preprocessed_binary(self) -> None:

for ses_name in self.sessions_and_runs.keys():
concat_recording = self._concatenate_runs(ses_name, recordings)

self.update_two_layer_dict(
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 392028e

Please sign in to comment.