Skip to content

Multiple radmc3dPy functions broken due to deprecation of np.int #46

Description

@cassandra-n-w

It seems that the deprecation of 'np.int' in recent versions of numpy has caused multiple functions in radmc3dPy to be nonfunctional.

I have attached an example error log below, showing what happens when the readMol() function is used. However, it is likely that this issue affects multiple other parts of the code as well.

The error log includes some recommendations about how to fix the error, and a numpy webpage detailing the change.

This is using numpy version 1.24.3.

Using an older numpy version should be a valid workaround for now, but some packages I work with are starting to require more-recent numpy versions.

Interestingly, despite numpy claiming the deprecation happened in numpy version 1.20, I have observed that this code does work in versions as recent as 1.21.2.

Reading molecule_oh2o.inp...
Traceback (most recent call last):

  File ~/anaconda3/envs/casa_radmc/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/hydrasim/plot_images.py:51
    h2o = readMol('oh2o')

  File ~/anaconda3/envs/casa_radmc/lib/python3.10/site-packages/radmc3dPy/analyze.py:496 in readMol
    if m.read(mol=mol, fname=fname) is True:

  File ~/anaconda3/envs/casa_radmc/lib/python3.10/site-packages/radmc3dPy/molecule.py:137 in read
    self.iup = np.zeros(self.nlin, dtype=np.int)

  File ~/anaconda3/envs/casa_radmc/lib/python3.10/site-packages/numpy/__init__.py:305 in __getattr__
    raise AttributeError(__former_attrs__[attr])

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


print(np.__version__)
1.24.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions