Commit f4a3de46 authored by Jörg Behrmann's avatar Jörg Behrmann
Browse files

Circumvent an error in test_dot for Numpy 1.12.0.

Numpy 1.12.0 updated iscomplexobj which always shows False for
tinyarrays, which makes assert_almost_equal fail for complex
array-valued arguments, as they will not be split up into real and
imaginary part. We circumvent this bug by testing every entry
separately in this case. This bug will be fixed for Numpy 1.12.1.

Fixes #11
parent 76c6432a
Pipeline #2715 passed with stages
in 3 minutes and 32 seconds
......@@ -228,8 +228,21 @@ def test_dot():
for sa, sb in shape_pairs:
a = make(sa, dtype)
b = make(sb, dtype) - 5
assert_almost_equal(ta.dot(ta.array(a), ta.array(b)), np.dot(a, b),
13)
dta = ta.dot(ta.array(a), ta.array(b))
dnp = np.dot(a, b)
# This circumvents a build error on Numpy 1.12.0, where numpy's
# iscomplexobj does not return True for complex tinyarrays.
# In this case we do the test per element.
if np.__version__ != '1.12.0':
assert_almost_equal(dta, dnp, 13)
elif (getattr(dta, "dtype", None) is complex and
getattr(dta, "shape", None) is not None and
len(dta) > 0):
idx = it.product(*[range(i) for i in dta.shape])
for i in idx:
assert_almost_equal(dta[i], dnp[i], 13)
else:
assert_almost_equal(dta, dnp, 13)
shape_pairs = [((), 2), (2, ()),
(1, 2),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment