Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While troubleshooting for #3348, I noticed some odd behavior with zarr-based sorting analyzers. Specifically, in some parts of the code, it seemed like the user would be permitted to pass a folder name with the
.zarr
suffix included (iefolder=/my/favorite/analyzer/
instead offolder=/my/favorite/analyzer.zarr/
). This led to two error cases when usingcreate_sorting_analyzer
if the user tried to make a new folder without the suffix:load_from_zarr
function didn't add the.zarr
suffix.overwrite=True
in the beginning of the function, it would not delete the folder (since the real folder has the.zarr
extension, but the user'sfolder
arg doesn't). But then later inSortingAnalyzer.create_zarr
there is another check for whether the folder exists, and when the suffix'd folder does indeed exist, it raises an error, defeating the point of theoverwrite
kwarg.This PR fixes that by:
clean_zarr_folder_name
incore_tools.py
that will check for a.zarr
suffix and add one if there isn't alreadymode="zarr"
, the folder passed to internal funcs always has.zarr
appended. Cleaning happens in:I also added cleaning in
SortingAnalyzer.create_zarr()
andSortingAnalyzer._save_or_select_or_merge()
themselves which might be redundant. Hopefully I didn't miss any other entry points but I haven't extensively tested.Obviously another solution here would be to insist that the user just put the
.zarr
suffix on themselves. But I like this way, as it allows for minimal change to a user's code (mode from binary_folder to zarr) and they will get the desired zarr behavior.