Hello,


I've found a small "bug" in larch when I tried to run the pre_edge function for some spectra. It seems that find_e0 will not accept a 2d 1-column array as input for energy or mu, and it gives a traceback which is quite difficult to decipher. Other functions like plot accepts these arrays without any problems, which made it a bit difficult to figure out what the problem was. Maybe there can be some some sort of warning if arrays have unexpected shapes, or an internal reshape if that works. I've attached a script that should give a minimum working example, my output is:


larch> run('cu.lar')
(612,)
8977.58
(612, 1)
  File "/usr/local/lib/python2.7/dist-packages/larch/__init__.py", line 37, in wrapper
    return fcn(*args, **keywords)
  File "/usr/share/larch/plugins/xafs/pre_edge.py", line 51, in find_e0
    dmu = np.gradient(mu)/np.gradient(energy)
  File "/usr/lib/python2.7/dist-packages/numpy/lib/function_base.py", line 918, in gradient
    out[slice1] = (f[slice2] - f[slice3])file cu.lar, line 14
IndexError: index 1 is out of bounds for axis 1 with size 1
    find_e0(e,cu.mu,group=cu)
  find_e0(e,cu.mu,group=cu)
file cu.lar, line 14
larch>


Best wishes,

Johan