Skip to content

AttributeError with np.float_ in distributional.py for NumPy>=2.0 #3

@orestiskapar

Description

@orestiskapar

I am facing an attribute error with the package in Python 3.12 combined with numpy==2.3.0. It probably has to do with numpy transitioning to float32/float64 properties for designating types.

Error stack trace:

    112 # Parse Hex string
    113 if isinstance(dist, str):
--> 114     return DistributionalValue._parse_ux_string(dist)
    115 # Parse byte array
    116 elif isinstance(dist, (bytes, bytearray)):

File .venv/lib/python3.12/site-packages/signaloid/distributional/distributional.py:189, in DistributionalValue._parse_ux_string(text)
    187 dist_value.UR_type = representation_type
    188 dist_value.UR_order = dirac_delta_count
--> 189 dist_value.positions = np.array(support_position_list, dtype=np.float_)
    190 dist_value.masses = np.array(probability_mass_list, dtype=np.float_)
    191 dist_value.raw_masses = raw_probability_mass_list

File .venv/lib/python3.12/site-packages/numpy/__init__.py:781, in __getattr__(attr)
    778     raise AttributeError(__former_attrs__[attr], name=None)
    780 if attr in __expired_attributes__:
--> 781     raise AttributeError(
    782         f"`np.{attr}` was removed in the NumPy 2.0 release. "
    783         f"{__expired_attributes__[attr]}",
...
    789         "`np.chararray` is deprecated and will be removed from "
    790         "the main namespace in the future. Use an array with a string "
    791         "or bytes dtype instead.", DeprecationWarning, stacklevel=2)

AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.

One relevant line in code:

self.positions: NDArray[np.float_] = np.array([], dtype=np.float_)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions