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 'train_rng' referenced before assignment #18

Closed
alrichardbollans opened this issue Feb 16, 2022 · 1 comment
Labels
bug Something isn't working priority Something we'll try implement in the next release

Comments

@alrichardbollans
Copy link

alrichardbollans commented Feb 16, 2022

If no seed is given when initialising the Midas object, then no seed is passed to Midas.train_model() and so the variable train_rng is left unassigned (line 748) and this creates an error on line on 759 when a value for train_rng is expected.

I suspect this same issue will arise in other areas where if self.seed is not None: is used without a corresponding else statement (e.g. line 1184 in Midas.over_impute()).

I suspect this can be fixed by simply adding an else statement which generates a random seed and uses this to assign a value to train_rng

Interpreter settings:
Python 3.9

numpy~=1.22.1
pandas~=1.3.5

scipy==1.8.0
matplotlib~=3.5.1
scikit-learn~=1.0.1
tensorflow==2.8.0
keras~=2.6.0
graphviz~=0.19
MIDASpy~=1.2.1
statsmodels~=0.13.2

@tsrobinson tsrobinson added bug Something isn't working priority Something we'll try implement in the next release labels Mar 24, 2022
@tsrobinson
Copy link
Collaborator

Thanks @alrichardbollans and apologies for the delay in getting back to you. I agree, and will implement asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Something we'll try implement in the next release
Projects
None yet
Development

No branches or pull requests

2 participants