Skip to content
Snippets Groups Projects
Commit 136e4675 authored by David Gobbi's avatar David Gobbi
Browse files

Numpy v2 takes additional __array_wrap__ parameter

Without the return_scalar parameter, numpy 2.x reports a deprecation
warning when numpy_interface is used with ufuncs.
parent 9588f7a2
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,9 @@ except ImportError:
raise RuntimeError("This module depends on the numpy module. Please make\
sure that it is installed properly.")
# version 2 has many API changes from version 1
NUMPY_MAJOR_VERSION = int(numpy.__version__.split('.')[0])
import itertools
import operator
import sys
......@@ -293,8 +296,8 @@ class VTKArray(numpy.ndarray):
(self.__class__.__name__, name))
return getattr(o, name)
def __array_wrap__(self, out_arr, context=None):
if out_arr.shape == ():
def __array_wrap__(self, out_arr, context=None, return_scalar=False):
if return_scalar or (NUMPY_MAJOR_VERSION < 2 and out_arr.shape == ()):
# Convert to scalar value
return out_arr[()]
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment