zblz / naima

Derivation of non-thermal particle distributions through MCMC spectral fitting
http://naima.readthedocs.io
BSD 3-Clause "New" or "Revised" License
43 stars 54 forks source link

Error while running example #195

Closed Lancelot-Ac closed 4 years ago

Lancelot-Ac commented 4 years ago

Dear all,

A TypeError was reported while I run the "Fitting IC emission from an electron distribution" example given in https://naima.readthedocs.io/en/latest/examples.html

WARNING: "cl" keyword not provided in input data table, upper limits will be assumed to be at 90% confidence level [naima.utils]
INFO: Finding Maximum Likelihood parameters through Nelder-Mead fitting... [naima.core]
INFO:    Initial parameters: [6.97875803e+25 3.00000000e+00 1.47712125e+00] [naima.core]
Traceback (most recent call last):
  File "test2.py", line 87, in <module>
    prefit=True,
  File "/home/hanl/softwares/miniconda3/envs/naima/lib/python3.7/site-packages/naima/core.py", line 550, in run_sampler
    sampler, pos = get_sampler(**kwargs)
  File "/home/hanl/softwares/miniconda3/envs/naima/lib/python3.7/site-packages/naima/core.py", line 478, in get_sampler
    p0, P0_IS_ML = _prefit(p0, data, model, prior)
  File "/home/hanl/softwares/miniconda3/envs/naima/lib/python3.7/site-packages/naima/core.py", line 204, in _prefit
    "   Initial lnprob(p0): {0:.3f}".format(-nll(p0, data, model, prior))
  File "/home/hanl/softwares/miniconda3/envs/naima/lib/python3.7/site-packages/naima/core.py", line 197, in nll
    return -lnprob(*args)[0]
  File "/home/hanl/softwares/miniconda3/envs/naima/lib/python3.7/site-packages/naima/core.py", line 123, in lnprob
    if np.array_equal(blob, model):
  File "<__array_function__ internals>", line 6, in array_equal
TypeError: no implementation found for 'numpy.array_equal' on types that implement __array_function__: [<class 'astropy.units.quantity.Quantity'>]

My python version is 3.7.5, naima version is 0.9.0, astropy version is 4.0 and numpy version is 1.17.4. I wonder if the problem was caused by the version of astropy?

Thanks for your attention.

zblz commented 4 years ago

Hi @Lancelot-Ac, thanks for reporting this. It has been fixed in #196, which is part of the newly released version 0.9.1.