Skip to content

Use of deprecated np.float results in crash when calling pg.functions.colorDistance([]) #2738

@MalteOlle

Description

@MalteOlle

Short description

Calling pg.functions.colorDistance([]) raises an error when using numpy >= 1.20, because np.float is deprecated, see https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations.

Code to reproduce

import pyqtgraph as pg

pg.functions.colorDistance([])

Expected behavior

return an empty array

Real behavior

  File "...\pyqtgraph\functions.py", line 549, in colorDistance
    if len(colors) < 1: return np.array([], dtype=np.float)
  File "...\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

Tested environment(s)

  • PyQtGraph version: 0.13.4dev0
  • Qt Python binding:
  • Python version: PySide6 6.5.1 Qt 6.5.1
  • NumPy version: 1.24.3
  • Operating system: Windows
  • Installation method: conda environment (python 3.9.16) + python -m pip install numpy scipy pyside6 -e .

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions