Skip to content
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

Fix UnboundLocalError by ensuring 'out' variable is always initialized #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ruose1314
Copy link

The issue was in the load_array function, line 651, it would raise an UnboundLocalError since the returned variable 'out' is defined in if statement, I Initialized 'out' to 'None' at the start of the function to ensure it's always defined (line 671).

@marklescroart
Copy link
Member

Thanks for pointing this out, there is an issue here, but I don't think this is the correct fix. It sounds like you have run into a case for which the file extension is not known - what was the file you were trying to load? It must not have been '.mat'., '.mp4', '.npy', or any of the possible hdf file extensions ('.hdf', '.hf', '.hdf5', '.h5', '.hf5'). If that's the case, better to throw a not-supported error (NotImplementedError) for the particular file type than to simply return none. This should be done with an else statement following the other if and elif statements that govern loading of other file types. Can you make this change instead, and I'll accept the pull request?

@marklescroart
Copy link
Member

In cleaning up some outstanding issues - this still seems worth doing. @ruose1314 , want to do this? Or should I? (we may need to rebase to merge at this point, might be a good exercise)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants