Skip to content

climetlab is not numpy 2 compliant (numpy.NaN is deprecated) #70

@thebaptiste

Description

@thebaptiste

What happened?

I tried to use climetlab with numpy 2.0.2 on Python 3.12
import climetlab fails because numpy.NaN is used in hurricane_database.py
I used release 0.20.1 but it would have been the same with more recent releases as this is not fixed (I couldn't use 0.24.0 because of issue #69)

What are the steps to reproduce the bug?

Build climetlab from sources with numpy 2.0.2
Then use it with a program using hurricane_database.py

Version

v0.20.1

Platform (OS and architecture)

RockyLinux 8

Relevant log output

`  File "/src/integration_tests/0010_climetlab/climetlab_test.py", line 6, in <module>
    atlantic = cml.load_dataset("hurricane-database", bassin="atlantic")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-experimental_numpy2/opt/python3_scientific/lib/python3.12/site-packages/climetlab/datasets/__init__.py", line 280, in load_dataset
    ds = klass(*args, **kwargs).mutate()
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-experimental_numpy2/opt/python3_scientific/lib/python3.12/site-packages/climetlab/core/__init__.py", line 25, in __call__
    obj.__init__(*args, **kwargs)
  File "/opt/metwork-mfext-experimental_numpy2/opt/python3_scientific/lib/python3.12/site-packages/climetlab/datasets/hurricane_database.py", line 101, in __init__
    pressure = np.NaN if line[43] == "-" else float(line[43:47])
               ^^^^^^
  File "/opt/metwork-mfext-experimental_numpy2/opt/python3_scientific/lib/python3.12/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.. Did you mean: 'nan'?``

Accompanying data

No response

Organisation

Meteo-France

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions