summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-06-18 10:27:35 -0600
committerGitHub <noreply@github.com>2017-06-18 10:27:35 -0600
commit1d9189e5de35c8a0a31dd219e4dced96a4bd9ee9 (patch)
treeff4f8c55e8d3bf28774788de236894e53377d303 /numpy/lib/tests/test_function_base.py
parent3ff00b18661a0106c91177c87f0a137994a62f3a (diff)
parent47242a25920e72366e906a7ffaa2fb41144623d3 (diff)
downloadnumpy-1d9189e5de35c8a0a31dd219e4dced96a4bd9ee9.tar.gz
Merge pull request #9259 from soupault/fix_9251
MAINT: Use XOR for bool arrays in `np.diff`
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 7479e30b3..4000b55f5 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -638,6 +638,16 @@ class TestDiff(TestCase):
assert_array_equal(diff(x, n=2), out2)
assert_array_equal(diff(x, n=3), out3)
+ x = [1.1, 2.2, 3.0, -0.2, -0.1]
+ out = np.array([1.1, 0.8, -3.2, 0.1])
+ assert_almost_equal(diff(x), out)
+
+ x = [True, True, False, False]
+ out = np.array([False, True, False])
+ out2 = np.array([True, True])
+ assert_array_equal(diff(x), out)
+ assert_array_equal(diff(x, n=2), out2)
+
def test_nd(self):
x = 20 * rand(10, 20, 30)
out1 = x[:, :, 1:] - x[:, :, :-1]
@@ -927,7 +937,7 @@ class TestGradient(TestCase):
assert_raises(ValueError, gradient, np.arange(0), edge_order=2)
assert_raises(ValueError, gradient, np.arange(1), edge_order=1)
assert_raises(ValueError, gradient, np.arange(1), edge_order=2)
- assert_raises(ValueError, gradient, np.arange(2), edge_order=2)
+ assert_raises(ValueError, gradient, np.arange(2), edge_order=2)
class TestAngle(TestCase):