bbalasub1 / glmnet_python

GNU General Public License v3.0
199 stars 94 forks source link

unbound variable for `glmnetPlot` #18

Closed zym1010 closed 5 years ago

zym1010 commented 6 years ago

when running the notebook example in https://github.com/bbalasub1/glmnet_python/blob/master/test/glmnet_examples.ipynb,

under multinomial logistic regression, the line glmnetPlot(fit, xvar = 'lambda', label = True, ptype = '2norm'); will crash.

UnboundLocalError                         Traceback (most recent call last)
<ipython-input-40-4a1bdfbf6536> in <module>()
----> 1 glmnetPlot(fit, xvar = 'lambda', label = True, ptype = '2norm');

/home/yimengzh/miniconda2/envs/pytorch/lib/python3.6/site-packages/glmnet_python-0.2.0-py3.6.egg/glmnet_python/glmnetPlot.py in glmnetPlot(x, xvar, label, ptype, **options)
    121                 handle = plotCoef(coefnorm, norm, x['lambdau'], dfseq, x['dev'],
    122                          label, xvar, '',str, **options);
--> 123                 if i < ncl - 1:
    124                     plt.figure()
    125             else:

UnboundLocalError: local variable 'ncl' referenced before assignment

checking the source code, seems that ncl is undefined in this conditional branch. Looks that it's not some life-or-death error. Still, it's troublesome.

I installed from source, from commit 18e6d6c

bbalasub1 commented 5 years ago

This was a bug in the source code. The bug has been fixed now.