Skip to content

Commit a8a46d7

Browse files
committed
numpy 1.21 unknown arguments error workaround
1 parent 79f60e2 commit a8a46d7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_numpy_functions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
3+
from packaging import version
34

4-
from numpy.lib.arraysetops import isin
55
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
66

77

@@ -183,12 +183,19 @@ def test_ndarray_methods():
183183
assert (r == ra).all()
184184

185185
def test_outputs_formats():
186+
186187
values = [[1, 2, 3], [-1, 0, 1]]
187188
w = Fxp(values, True, 16, 8)
188189
like_ref = Fxp(None, True, 24, 12)
189190
out_ref = Fxp(None, True, 24, 8)
190191

191-
z = np.add(w, 2, out_like=like_ref)
192+
if version.parse(np.__version__) >= version.parse('1.21'):
193+
# since numpy 1.21 unknown arguments raise an error
194+
# by now only test the fxpmath.functions.add instead of numpy dispatched add function
195+
from fxpmath.functions import add
196+
z = add(w, 2, out_like=like_ref)
197+
else:
198+
z = np.add(w, 2, out_like=like_ref)
192199

193200
assert isinstance(z, Fxp)
194201
assert z.n_frac == like_ref.n_frac

0 commit comments

Comments
 (0)