Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdms2 conflict with latest numpy version #449

Open
lee1043 opened this issue Nov 30, 2023 · 5 comments
Open

cdms2 conflict with latest numpy version #449

lee1043 opened this issue Nov 30, 2023 · 5 comments

Comments

@lee1043
Copy link

lee1043 commented Nov 30, 2023

numpy.float (e.g., used here is deprecated since numpy 1.20, need to replace it to numpy.float64.

f = cdms2.open(path) with latest numpy version returns below error.

 File "/Users/lee1043/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/cdms2/dataset.py", line 523, in openDataset
    file = CdmsFile(path, mode, hostObj)
  File "/Users/lee1043/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/cdms2/dataset.py", line 1348, in __init__
    self.variables[name] = FileVariable(
  File "/Users/lee1043/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/cdms2/fvariable.py", line 21, in __init__
    DatasetVariable.__init__(self, parent, varname)
  File "/Users/lee1043/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/cdms2/variable.py", line 74, in __init__
    self._numericType_ = numpy.float
  File "/Users/lee1043/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
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

I understand cdms2 is no longer under active development, so leaving this error for documenting it.

@jypeter
Copy link
Member

jypeter commented Nov 30, 2023

Good idea to this documentation issue!

Do you know precisely which version of numpy is the last one compatible with cdms2 (i.e. where np.float is deprecated, but still available)? You may then update the issue title to include this information, like cdms2 is incompatible with numpy > vvvvv

I have just checked my current (though slightly obsolete) environment, and np.float is still available in numpy 1.21.4

(cdatm_py3)  >conda list | egrep '(cdms|numpy)'
cdms2                     3.1.5                    pypi_0    pypi
libcdms                   3.1.2              h981a4fd_113    conda-forge
numpy                     1.21.4           py38he2449b9_0    conda-forge
numpy_groupies            0.9.22             pyhd8ed1ab_0    conda-forge
numpydoc                  1.1.0                      py_1    conda-forge

(cdatm_py3)  >python
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> fl_test = np.float(3)
<stdin>:1: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
>>> fl_test
3.0
>>> type(fl_test)
<class 'float'>
>>>

@jypeter
Copy link
Member

jypeter commented Nov 30, 2023

I have just found this old issue, that seemed to deal with handling new data types

Update cdms2 to deal with all common datatypes (uint8, uint16, char, str etc)

If, by chance, an existing issue documents an easy way to update all the required types, and a knowledgeable person (that's not me) can implement a quick fix of cdms2, it would not hurt ! <3

@lee1043
Copy link
Author

lee1043 commented Nov 30, 2023

Good idea, I think the last numpy version that works with cdms2 is 1.23.5.

https://stackoverflow.com/questions/74844262/how-can-i-solve-error-module-numpy-has-no-attribute-float-in-python

  • NumPy 1.20 (release notes) deprecated numpy.float, numpy.int, and similar aliases, causing them to issue a deprecation warning

  • NumPy 1.24 (release notes) removed these aliases altogether, causing an error when they are used

@lee1043 lee1043 changed the title Issue with latest numpy version cdms conflict with latest numpy version Dec 1, 2023
@lee1043 lee1043 changed the title cdms conflict with latest numpy version cdms2 conflict with latest numpy version Dec 1, 2023
@xylar
Copy link
Contributor

xylar commented Oct 28, 2024

I believe this issue has been fixed in patches on conda-forge:
conda-forge/cdms2-feedstock#81
conda-forge/cdms2-feedstock#85

@xylar
Copy link
Contributor

xylar commented Oct 28, 2024

If you are installing a build of cdms2 from conda-forge >= 18, e.g.:

$ conda create -y -n test "python=3.10" "numpy>=1.24" cdms2
...
 cdms2              conda-forge/linux-64::cdms2-3.1.5-py310h4f3777b_23
...

and you're still encountering numpy-related errors, you might be best off reporting on conda-forge since CDAT is not really being maintained:
https://github.com/conda-forge/cdms2-feedstock/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants