Skip to content

Commit

Permalink
apply change also to cupy and numba codepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
pijyoi committed Apr 2, 2024
1 parent 3368bb2 commit b466c70
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pyqtgraph/functions.py
Expand Up @@ -1274,6 +1274,14 @@ def rescaleData(data, scale, offset, dtype=None, clip=None):
else:
work_dtype = np.float64

# from: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
# np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array.
# (The higher precision of the scalar is not ignored.)
# this affects us even though we are performing in-place operations.
# a solution mentioned in the link above is to convert to a Python scalar.
offset = float(offset)
scale = float(scale)

cp = getCupy()
if cp and cp.get_array_module(data) == cp:
# Cupy does not support nditer
Expand All @@ -1295,14 +1303,6 @@ def rescaleData(data, scale, offset, dtype=None, clip=None):
# if we got here by makeARGB(), clip will not be None at this point
return numba_fn.rescaleData(data, scale, offset, out_dtype, clip)

# from: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
# np.array([3], dtype=np.float32) + np.float64(3) will now return a float64 array.
# (The higher precision of the scalar is not ignored.)
# this affects us even though we are performing in-place operations.
# a solution mentioned in the link above is to convert to a Python scalar.
offset = float(offset)
scale = float(scale)

return _rescaleData_nditer(data, scale, offset, work_dtype, out_dtype, clip)


Expand Down

0 comments on commit b466c70

Please sign in to comment.