summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-09-21 13:33:25 -0500
committerGitHub <noreply@github.com>2017-09-21 13:33:25 -0500
commit92d08dbcc9f489e54aeab8525b4b30f7b5d01ecf (patch)
treefe1476d1a20a476b50a027c9ae5f4f6bf0e68055 /numpy/lib/tests/test_function_base.py
parent54232da2f1c1d65f01c747eb7d1dda8fd46d6a63 (diff)
parent1f4ba5bee1240cc7a888087dc06acb7709f12870 (diff)
downloadnumpy-92d08dbcc9f489e54aeab8525b4b30f7b5d01ecf.tar.gz
Merge pull request #9408 from eric-wieser/gradient-fix
BUG: various fixes to np.gradient
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 4c90abbf6..c64081088 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -804,8 +804,11 @@ class TestGradient(object):
# distances must be scalars or have size equal to gradient[axis]
gradient(np.arange(5), 3.)
+ gradient(np.arange(5), np.array(3.))
gradient(np.arange(5), dx)
- gradient(f_2d, 1.5) # dy is set equal to dx because scalar
+ # dy is set equal to dx because scalar
+ gradient(f_2d, 1.5)
+ gradient(f_2d, np.array(1.5))
gradient(f_2d, dx_uneven, dx_uneven)
# mix between even and uneven spaces and
@@ -815,6 +818,10 @@ class TestGradient(object):
# 2D but axis specified
gradient(f_2d, dx, axis=1)
+ # 2d coordinate arguments are not yet allowed
+ assert_raises_regex(ValueError, '.*scalars or 1d',
+ gradient, f_2d, np.stack([dx]*2, axis=-1), 1)
+
def test_badargs(self):
f_2d = np.arange(25).reshape(5, 5)
x = np.cumsum(np.ones(5))