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

UnboundLocalError: local variable 'dxy' referenced before assignment #48

Closed
bernatp3rs opened this issue Mar 3, 2021 · 3 comments
Closed
Assignees
Labels
bug Code that is failing or producing the wrong result question Queries about using tobac or how the code works

Comments

@bernatp3rs
Copy link

Hi,

I am trying to use TOBAC but I always get the same error:
dxy,dt=tobac.get_spacings(Precip)
File "/usr/local/anaconda3/envs/my_env36/lib/python3.6/site-packages/tobac/utils.py", line 450, in get_spacings
return dxy,dt
UnboundLocalError: local variable 'dxy' referenced before assignment

I cannot even run the following example:
https://github.com/climate-processes/tobac/blob/master/examples/Example_OLR_Tracking_model/Example_OLR_Tracking_model.ipynb

Does anybody know why is this happening?

@freemansw1
Copy link
Member

Hm, this is a bit of an odd case. I'm not sure why you would be getting this error as I don't see a path for dxy to be undefined. Either dxy is set here:
https://github.com/climate-processes/tobac/blob/d97517c3fd5af99defbb9fa5a9b924db37f6500d/tobac/utils.py#L436
or it is set here:
https://github.com/climate-processes/tobac/blob/d97517c3fd5af99defbb9fa5a9b924db37f6500d/tobac/utils.py#L438
and if neither if statement is triggered, a ValueError should be raised. What version of tobac are you using?

@freemansw1 freemansw1 added the question Queries about using tobac or how the code works label Jan 20, 2022
@freemansw1 freemansw1 self-assigned this Jan 20, 2022
@freemansw1 freemansw1 modified the milestone: Version 1.5 Mar 4, 2022
@JuliaKukulies
Copy link
Member

JuliaKukulies commented Apr 5, 2022

I realized that there is a typo (missing raise before ValueError in tobac/utils.py ) both in the old and newer versions, so that the ValueError would not be raised if the coordinates are not properly defined (see #5). I will fix this in tobac/utils/general.py for v2.0-dev.

@freemansw1
Copy link
Member

Great catch by Julia!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Code that is failing or producing the wrong result question Queries about using tobac or how the code works
Projects
None yet
Development

No branches or pull requests

3 participants