Clean up code around create_sorting_analyzer and create/load_* functions in sortinganalyzer.py#4680
Clean up code around create_sorting_analyzer and create/load_* functions in sortinganalyzer.py#4680ecobost wants to merge 11 commits into
Conversation
3349bd9 to
754c84f
Compare
| if not is_remote: | ||
| folder = clean_zarr_folder_name(folder) | ||
| if folder.is_dir(): | ||
| if folder.exists(): |
There was a problem hiding this comment.
why this change? is_dir() verifies existence and that it is a folder? So it's more specific.
There was a problem hiding this comment.
In here particularly, we don't actually care about it being a directory because we are gonna delete it anyway (whether a fle or directory); but actually we use exists everywhere so I'll change the ones where isdir/isfile will be more appropiate
There was a problem hiding this comment.
Well I think we try to use is_dir/is_file when possible, which I believe is better because more explicit, so I would revert
| if folder.exists(): | |
| if folder.is_dir(): |
There was a problem hiding this comment.
i did revert/change exists()-> is_dir/is_filewhen needed on the next commit below. But exists() makes more sense here, if someone says save it at /xxx/yyy and overwrite=True, then whatever is in /xxx/yyy (dir or file) will be overwritten
| recording.dump(recording_provenance_file, relative_to=folder) | ||
| elif recording.check_serializability("pickle"): | ||
| recording.dump(folder / "recording.pickle", relative_to=folder) | ||
| recording.dump(recording_provenance_file.with_suffix(".pickle"), relative_to=folder) |
There was a problem hiding this comment.
| recording.dump(recording_provenance_file, relative_to=folder) | |
| elif recording.check_serializability("pickle"): | |
| recording.dump(folder / "recording.pickle", relative_to=folder) | |
| recording.dump(recording_provenance_file.with_suffix(".pickle"), relative_to=folder) | |
| recording.dump(folder / "recording.json", relative_to=folder) | |
| elif recording.check_serializability("pickle"): | |
| recording.dump(folder / "recording.pickle", relative_to=folder) |
I think the previous version was cleaner. I don't see the point in defining the json path and change the suffix for pickle
There was a problem hiding this comment.
the idea was to signal the .json as the default output file; I could change it to
recording_provenance_file = folder / "recording" and then add the suffix at the dump line if you prefer
| if not is_remote: | ||
| folder = clean_zarr_folder_name(folder) | ||
| if folder.is_dir(): | ||
| if folder.exists(): |
There was a problem hiding this comment.
Well I think we try to use is_dir/is_file when possible, which I believe is better because more explicit, so I would revert
| if folder.exists(): | |
| if folder.is_dir(): |
|
@alejoe91 Couple of comments still open. Let me know when this version is ok to fix merge issues (don't wanna pollute current version) |
This PR does not functionally change much. It is mainly for code refactoring and to improve legibility.
The only two functional changes are:
spikeinterface/src/spikeinterface/core/base.py
Line 1087 in 39dfac4
Code quality improvements: