fermi-lat / Fermitools-conda

Conda recipe files for the Fermi Sciencetools software analysis package: Fermitools
https://fermi.gsfc.nasa.gov/ssc/data/analysis/
BSD 3-Clause "New" or "Revised" License
34 stars 17 forks source link

np.float deprecation error #143

Open donhorner opened 1 year ago

donhorner commented 1 year ago

Numpy versions >1.2.0 deprecated some data types used by the Python code in the Fermitools, so recent installs of the tools have resulted errors when running pyLikelihood, e.g.,

AttributeError: module 'numpy' has no attribute 'float'. np.float was a deprecated alias for the builtin float. To avoid this error in existing code, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

The FSSC needs to go through the Fermitool python code, fix any places this occurs, and check for any other deprecation in recent Numpy releases that might affect the tools.

Until we get it fixed, users can get a working version by pinning the Numpy version to the last Numpy that allowed deprecated types, e.g.,

conda install -n fermitools -c conda-forge -c fermi numpy=1.20

dagorym commented 1 year ago

Do we have any specific examples? Doing a quick grep on np.float only returns 5 instances in the entire code base, one in BayesianBlocks and four in pyBurstAnalysisGUI. If that's really all there is, this will be quick.

donhorner commented 1 year ago

If you install a fresh version of the tools and try to run the Python thread, you should get the error when running UnbinnedAnalysis. Make sure that we're not using any of the other deprecated data types in 1.20.0. It looks like Numpy is up to 1.25.0, so check if there was anything else deprecated in later versions that would affect us, too.

kerrm commented 1 year ago

Just to be thorough: np.int is also going away.

dagorym commented 1 year ago

That was my plan. I was going to work through all of deprecation notes and see what I find.

amritphy commented 8 months ago

I am working with UnbinnedAnalysis and the error still persists. I am on fermitools 2.2.0. Is there a new release of the software yet?

nmirabal commented 8 months ago

If working in python, please try the following before importing the UnbinnedAnalysis

import numpy as np np.float=float