xraypy/xraylarch

xas_viewer passing nnorm as float instead of int

Closed this issue · 2 comments

maurov commented

Larch 0.9.70 on a Linux Ubuntu 20.04 machine

The GUI is wrongly passing a float instead of int to the nnorm parameter of pre_edge. This giving the following error:

pre_edge(cump0, pre1=-62.77, pre2=-30.00, nvict=0.00, nnorm=1.00, norm1=200.00, norm2=534.77)
Traceback (most recent calls last): 
    pre_edge(cump0, pre1=-62.77, pre2=-30.00, nvict=0.00, nnorm=1.00, norm1=200.00, norm2=534.77)
   File /users/opd30/.larch/init.lar, line 1
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/larch/closure.py", line 76, in __call__
    return self.func(*args, **kwds)
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/larch/larchlib.py", line 531, in wrapper
    result = fcn(*args, **kwargs)
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/larch/xafs/pre_edge.py", line 277, in pre_edge
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/larch/xafs/pre_edge.py", line 189, in preedge
    post_edge += c * energy**(n)
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/larch/math/utils.py", line 440, in polyfit
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/numpy/polynomial/_polybase.py", line 1037, in fit
    res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full)
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/numpy/polynomial/polynomial.py", line 1362, in polyfit
    return pu._fit(polyvander, x, y, deg, rcond, full, w)
  File "/nobackup/joconde1/mambaforge/envs/sloth/lib/python3.9/site-packages/numpy/polynomial/polyutils.py", line 616, in _fit
    raise TypeError("deg must be an int or non-empty 1-D array of int")

TypeError: deg must be an int or non-empty 1-D array of int

I will further investigate it.

@maurov yeah, sorry, I think this is fixed in master now....

maurov commented

@newville thanks for fixing this so quickly (2afcf1a)!