-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix/Fix UnboundLocalError
in TiffGlobReader
#449
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me! Will get one more approval. Thanks!
Does |
Thanks for the contribution! Any chance you might be able to add some tests for this particular case as well? 😄 |
It should: https://github.com/AllenCellModeling/aicsimageio/blob/main/aicsimageio/types.py#L14 but without seeing the error I am not sure where it might be going wrong. Haven't looked at this code since the PR that added it |
edit: hang on I may have pasted the wrong thing |
Codecov ReportBase: 93.90% // Head: 94.00% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #449 +/- ##
==========================================
+ Coverage 93.90% 94.00% +0.10%
==========================================
Files 46 46
Lines 4001 4021 +20
==========================================
+ Hits 3757 3780 +23
+ Misses 244 241 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Somehow I've managed to end up with a
In particular |
Maybe related: I think that this line: aicsimageio/aicsimageio/readers/tiff_glob_reader.py Lines 176 to 178 in f789666
should really be making a copy of the dataframe, as it stands the code modifies the object the user passes which can be confusing when you look back at the dataframe. |
Ok! I figured out the source of my folder = "data/run_10/"
files = pd.Series(Path(folder).glob("*.tiff"))
index = files.apply(indexer)
# remove time points where we didn't collect every position
idx = index_complete_timepoints(index)
# This line is causing the problem!
# makes the index.index no longer continuous
# this would all work, except that because I have to stringify filenames
# we lose the same treatment to the files index
# and then there are alignment issues
index = index.loc[idx]
files = files.loc[idx]
# make list to work around https://github.com/AllenCellModeling/aicsimageio/pull/449
filenames = [str(f) for f in files]
reader = TiffGlobReader(filenames, indexer=index) I need to filter out some files (because I had some partially completed timepoints) so the pandas indices were ending up misaligned because the filenames |
UnboundLocalError
in TiffGlobReaderUnboundLocalError
in TiffGlobReader
Ok. Now has tests and I fixed the not copying dataframe/series, the index alignment, and also allowed np.arrays for the list of filenames |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still good with this! Thanks for finding all the various oddities!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you for adding tests! I have one suggested improvement to the test but nothing to stop a merge 😄
Co-authored-by: Madison Swain-Bowden <bowdenm@spu.edu>
ooh hang on. before merging I think I also need to update the typing on the parameters to reflect the new options. Is it ok to go to |
I think I did this successfully in the following two commits - so all good from me to merge :) |
Merging now! Thanks for the multiple bug fixes! |
Description
I passed a
pd.Series
of files toTiffGlobReader
and got this error:UnboundLocalError: local variable 'file_series' referenced before assignment
.This prevents that error by raising a
TypeError
if passed an invalid type, and also allows forglob_in
to be a pandas series.As ever for tiffglobreader cc @jrussell25
Pull request recommendations:
Thanks for contributing!