MIDASverse / MIDASpy

Python package for missing-data imputation with deep learning
Apache License 2.0
125 stars 35 forks source link

UnboundLocalError: local variable 'train_rng' referenced before assignment #18

Closed alrichardbollans closed 2 years ago

alrichardbollans commented 2 years ago

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 commented 2 years ago

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