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 9 commits into
Conversation
3349bd9 to
754c84f
Compare
| zarr_path = cache_folder / f"{name}.zarr" | ||
| if verbose: | ||
| print(f"Use zarr_path={zarr_path}") | ||
| else: |
There was a problem hiding this comment.
where did this else go? If a name is specified we should accept their name right? I haven't read this for a while.
There was a problem hiding this comment.
logic before was if name is None, -> [create random name as name, create zarr_path] else [create_zarr_path]. Now, the logic is if name is none-> [create_random_name] -> (always) create_zarr_path. The only difference is in whether something is printed. Assuming verbose=True, before if name is None, print "using zarr folder", else if name was provided but not is_set_global_tmp_folder, then print "using zarr folder..." , now it always prints (when verbose=True). I think it's worth it for simpler code
|
|
||
| # Typing hints | ||
| PeakSignType = Literal["both", "neg", "pos"] | ||
| PeakModeType = Literal["extremum", "at_index", "peak_to_peak"] |
There was a problem hiding this comment.
There was some debate about whether people liked this or not. Someone else had proposed doing this and we decided against it at the time, but maybe people have changed their minds?
There was a problem hiding this comment.
Otherwise I had to repeat Literal["both", "neg", "pos"] in a bunch of places. And in theory if later an option was added to the list also add that option in a bunch of places. I'm ok either way, it's just variables
| 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
| "The zarr store was not consolidated prior to v0.101.1. " | ||
| "This may lead to unexpected behavior in loading extensions. " | ||
| "Please consider re-generating the SortingAnalyzer object." | ||
| "Consider re-generating the SortingAnalyzer object." |
There was a problem hiding this comment.
I thought Consider re-generating was weak enough already :) and more direct. We are not even telling them to re-generate it but to consider it, Won't die on this hill though
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: