summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-12-11 13:58:10 +0200
committerGitHub <noreply@github.com>2019-12-11 13:58:10 +0200
commit5856c486ac5dd62a6ac9b2a861aa86802e6e0edd (patch)
treedfe7c0385533c4c1d9209402a689476edfff9be2 /numpy/lib/tests
parentc01014507c6f128394ba1a66f91ef32fc94bbeba (diff)
parenta483acce85e6a35a5da0f46aeddd05b33f6d612c (diff)
downloadnumpy-5856c486ac5dd62a6ac9b2a861aa86802e6e0edd.tar.gz
Merge pull request #14981 from seberg/issue-13103
This reverts commit c088383cb290ca064d456e89d79177a0e234cb8d and uses the same kind casting rule for the additional keyword arguments ``to_end`` and ``to_begin``. This results in slightly more leniant behaviour for integers (which can now have overflows that are hidden), but fixes an issue with the handling of NaN. Generally, this behaviour seems more conistent with what NumPy does elsewhere. The Overflow issue exists similar in many other places and should be solved by integer overflow warning machinery while the actual cast takes place. Closes gh-13103
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_arraysetops.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index fd21a7f76..1d38d8d27 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -135,9 +135,9 @@ class TestSetOps(object):
None,
np.nan),
# should fail because attempting
- # to downcast to smaller int type:
- (np.array([1, 2, 3], dtype=np.int16),
- np.array([5, 1<<20, 2], dtype=np.int32),
+ # to downcast to int type:
+ (np.array([1, 2, 3], dtype=np.int64),
+ np.array([5, 7, 2], dtype=np.float32),
None),
# should fail because attempting to cast
# two special floating point values
@@ -152,8 +152,8 @@ class TestSetOps(object):
# specifically, raise an appropriate
# Exception when attempting to append or
# prepend with an incompatible type
- msg = 'cannot convert'
- with assert_raises_regex(ValueError, msg):
+ msg = 'must be compatible'
+ with assert_raises_regex(TypeError, msg):
ediff1d(ary=ary,
to_end=append,
to_begin=prepend)
@@ -163,9 +163,13 @@ class TestSetOps(object):
"append,"
"expected", [
(np.array([1, 2, 3], dtype=np.int16),
- 0,
+ 2**16, # will be cast to int16 under same kind rule.
+ 2**16 + 4,
+ np.array([0, 1, 1, 4], dtype=np.int16)),
+ (np.array([1, 2, 3], dtype=np.float32),
+ np.array([5], dtype=np.float64),
None,
- np.array([0, 1, 1], dtype=np.int16)),
+ np.array([5, 1, 1], dtype=np.float32)),
(np.array([1, 2, 3], dtype=np.int32),
0,
0,
@@ -187,6 +191,7 @@ class TestSetOps(object):
to_end=append,
to_begin=prepend)
assert_equal(actual, expected)
+ assert actual.dtype == expected.dtype
def test_isin(self):