ARM-DOE / pyart

The Python-ARM Radar Toolkit. A data model driven interactive toolkit for working with weather radar data.
https://arm-doe.github.io/pyart/
Other
495 stars 262 forks source link

Errors with Updated NumPy2.0 #1608

Open RBhupi opened 2 weeks ago

RBhupi commented 2 weeks ago

Description

After updating NumPy2.0, following error is raised due to the removal of np.unicode_ while loading the pyart packages.

What I Did

  1. create environment and install NumPy 2.0.
  2. Import Py-ART in a JuPyter Notebook.
  3. Got the Error .
{
    "name": "AttributeError",
    "message": "`np.unicode_` was removed in the NumPy 2.0 release. Use `np.str_` instead.",
    "stack": "---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 4
      1 #import xarray as xr
      2 #import xradar as xd
      3 import glob
----> 4 import pyart
      5 import pandas as pd
      7 import matplotlib.pyplot as plt

File ~/data-env1/lib/python3.12/site-packages/pyart/__init__.py:29
     25 import importlib.metadata as _importlib_metadata
     27 # import subpackages
     28 # print out helpful message if build fails or importing from source tree
---> 29 from . import (
     30     __check_build,  # noqa
     31     aux_io,  # noqa
     32     bridge,  # noqa
     33     config,  # noqa
     34     core,  # noqa
     35     correct,  # noqa
     36     filters,  # noqa
     37     graph,  # noqa
     38     io,  # noqa
     39     map,  # noqa
     40     retrieve,  # noqa
     41     testing,  # noqa
     42     util,  # noqa
     43     xradar,  # noqa
     44 )
     45 from ._debug_info import _debug_info  # noqa
     47 # root level functions

File ~/data-env1/lib/python3.12/site-packages/pyart/aux_io/__init__.py:16
      1 \"\"\"
      2 Additional classes and functions for reading and writing data from a number
      3 of file formats.
   (...)
     13 
     14 \"\"\"
---> 16 from .arm_vpt import read_kazr  # noqa
     17 from .d3r_gcpex_nc import read_d3r_gcpex_nc  # noqa
     18 from .edge_netcdf import read_edge_netcdf  # noqa

File ~/data-env1/lib/python3.12/site-packages/pyart/aux_io/arm_vpt.py:13
     10 import numpy as np
     12 from ..config import FileMetadata
---> 13 from ..core.radar import Radar
     14 from ..io import cfradial
     17 def read_kazr(
     18     filename,
     19     field_names=None,
   (...)
     23     include_fields=None,
     24 ):

File ~/data-env1/lib/python3.12/site-packages/pyart/core/__init__.py:6
      1 \"\"\"
      2 Core Py-ART classes and function for interacting with weather radar data.
      3 
      4 \"\"\"
----> 6 from .grid import Grid  # noqa
      7 from .radar import Radar  # noqa
      8 from .radar_spectra import RadarSpectra  # noqa

File ~/data-env1/lib/python3.12/site-packages/pyart/core/grid.py:10
      7 from netCDF4 import num2date
      9 try:
---> 10     import xarray
     12     _XARRAY_AVAILABLE = True
     13 except ImportError:

File ~/data-env1/lib/python3.12/site-packages/xarray/__init__.py:1
----> 1 from xarray import testing, tutorial
      2 from xarray.backends.api import (
      3     load_dataarray,
      4     load_dataset,
   (...)
      8     save_mfdataset,
      9 )
     10 from xarray.backends.zarr import open_zarr

File ~/data-env1/lib/python3.12/site-packages/xarray/testing.py:10
      7 import numpy as np
      8 import pandas as pd
---> 10 from xarray.core import duck_array_ops, formatting, utils
     11 from xarray.core.dataarray import DataArray
     12 from xarray.core.dataset import Dataset

File ~/data-env1/lib/python3.12/site-packages/xarray/core/duck_array_ops.py:36
     33 from numpy.core.multiarray import normalize_axis_index  # type: ignore[attr-defined]
     34 from numpy.lib.stride_tricks import sliding_window_view  # noqa
---> 36 from xarray.core import dask_array_ops, dtypes, nputils
     37 from xarray.core.parallelcompat import get_chunked_array_type, is_chunked_array
     38 from xarray.core.pycompat import array_type, is_duck_dask_array

File ~/data-env1/lib/python3.12/site-packages/xarray/core/dask_array_ops.py:3
      1 from __future__ import annotations
----> 3 from xarray.core import dtypes, nputils
      6 def dask_rolling_wrapper(moving_func, a, window, min_count=None, axis=-1):
      7     \"\"\"Wrapper to apply bottleneck moving window funcs on dask arrays\"\"\"

File ~/data-env1/lib/python3.12/site-packages/xarray/core/dtypes.py:43
     33 NINF = AlwaysLessThan()
     36 # Pairs of types that, if both found, should be promoted to object dtype
     37 # instead of following NumPy's own type-promotion rules. These type promotion
     38 # rules match pandas instead. For reference, see the NumPy type hierarchy:
     39 # https://numpy.org/doc/stable/reference/arrays.scalars.html
     40 PROMOTE_TO_OBJECT: tuple[tuple[type[np.generic], type[np.generic]], ...] = (
     41     (np.number, np.character),  # numpy promotes to character
     42     (np.bool_, np.character),  # numpy promotes to character
---> 43     (np.bytes_, np.unicode_),  # numpy promotes to unicode
     44 )
     47 def maybe_promote(dtype):
     48     \"\"\"Simpler equivalent of pandas.core.common._maybe_promote
     49 
     50     Parameters
   (...)
     57     fill_value : Valid missing value for the promoted dtype.
     58     \"\"\"

File ~/data-env1/lib/python3.12/site-packages/numpy/__init__.py:397, in __getattr__(attr)
    394     raise AttributeError(__former_attrs__[attr])
    396 if attr in __expired_attributes__:
--> 397     raise AttributeError(
    398         f\"`np.{attr}` was removed in the NumPy 2.0 release. \"
    399         f\"{__expired_attributes__[attr]}\"
    400     )
    402 if attr == \"chararray\":
    403     warnings.warn(
    404         \"`np.chararray` is deprecated and will be removed from \"
    405         \"the main namespace in the future. Use an array with a string \"
    406         \"or bytes dtype instead.\", DeprecationWarning, stacklevel=2)

AttributeError: `np.unicode_` was removed in the NumPy 2.0 release. Use `np.str_` instead."
}
zssherman commented 2 weeks ago

@RBhupi What xarray version do you have? Looks like the error might be coming from an outdated xarray version

mgrover1 commented 1 week ago

@RBhupi - following up here, which version of xarray are you using?

RBhupi commented 6 days ago

xarray 2023.6.0 py312h06a4308_0

mgrover1 commented 5 days ago

@RBhupi - you need to update your version of xarray to work with the latest version of numpy