dendrograms / astrodendro

Generate a dendrogram from a dataset
https://dendrograms.readthedocs.io/
Other
37 stars 36 forks source link

PyPI version (0.2.0) has unhandled package conflicts with Numpy >= 1.20 #189

Open taiwithers opened 1 year ago

taiwithers commented 1 year ago

0.2.0 version of astrodendro uses np.int, deprecated in Numpy 1.20. Installation documentation directs users to pip install, neither the release package nor the installation documentation notes this conflict.

Installation documentation and PyPI should probably both be updated to note the dependency, and perhaps documentation could be updated to recommend using the developer build to avoid this.

hamid-hassani commented 5 months ago

Exact error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 35
     31 import pandas as pd
     33 import matplotlib as mpl
---> 35 from astrodendro import Dendrogram, Structure, ppv_catalog, pruning
     37 # sys.path.append(os.path.join(os.getenv('HOME'),'python'))
     38 
     39 
   (...)
     49 # Peak finding routines
     50 # &%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%&%
     52 def lmax_from_assignment(data, assign, skipassign=0):

File /mnt/home/hhassani/anaconda3/lib/python3.9/site-packages/astrodendro/__init__.py:3
      1 # Licensed under an MIT open source license - see LICENSE
----> 3 from .dendrogram import Dendrogram, periodic_neighbours
      4 from .structure import Structure
      5 from .analysis import ppv_catalog, pp_catalog

File /mnt/home/hhassani/anaconda3/lib/python3.9/site-packages/astrodendro/dendrogram.py:23
     20     return sorted(d, key=lambda s: s.idx)
     22 # utility dict to offsets of adjacent pixel list
---> 23 _offsets = dict((ndim, np.concatenate((
     24                 np.identity(ndim),
     25                 np.identity(ndim) * -1)).astype(np.int))
     26                 for ndim in range(1, 8))
     28 # the formula above generalizes this special case
     29 #_offsets[3] = np.array([(0, 0, -1), (0, 0, 1),
     30 #                        (0, -1, 0), (0, 1, 0),
     31 #                        (-1, 0, 0), (1, 0, 0)])
     34 class Dendrogram(object):

File /mnt/home/hhassani/anaconda3/lib/python3.9/site-packages/astrodendro/dendrogram.py:25, in <genexpr>(.0)
     20     return sorted(d, key=lambda s: s.idx)
     22 # utility dict to offsets of adjacent pixel list
     23 _offsets = dict((ndim, np.concatenate((
     24                 np.identity(ndim),
---> 25                 np.identity(ndim) * -1)).astype(np.int))
     26                 for ndim in range(1, 8))
     28 # the formula above generalizes this special case
     29 #_offsets[3] = np.array([(0, 0, -1), (0, 0, 1),
     30 #                        (0, -1, 0), (0, 1, 0),
     31 #                        (-1, 0, 0), (1, 0, 0)])
     34 class Dendrogram(object):

File /mnt/home/hhassani/anaconda3/lib/python3.9/site-packages/numpy/__init__.py:324, in __getattr__(attr)
    319     warnings.warn(
    320         f"In the future `np.{attr}` will be defined as the "
    321         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    323 if attr in __former_attrs__:
--> 324     raise AttributeError(__former_attrs__[attr])
    326 if attr == 'testing':
    327     import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
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