summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
diff options
context:
space:
mode:
authorMarten van Kerkwijk <mhvk@astro.utoronto.ca>2017-04-27 22:26:35 -0400
committerGitHub <noreply@github.com>2017-04-27 22:26:35 -0400
commitd5657b9e29a8e00ad8e074bc32c15dec220d766f (patch)
tree4234edb850b59e3bf6763fa10ae0ab4dff6f4b00 /numpy/lib/tests
parenta495bb9a8bdd8e30372d9dcf7e3ca777a8670ab2 (diff)
parent05f422827b3317ad3774cbd1859edbf6bc196f75 (diff)
downloadnumpy-d5657b9e29a8e00ad8e074bc32c15dec220d766f.tar.gz
Merge pull request #8996 from eric-wieser/fix-ufunclike
BUG/DEP: Make ufunclike functions more ufunc-like
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r--numpy/lib/tests/test_ufunclike.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_ufunclike.py b/numpy/lib/tests/test_ufunclike.py
index 97d608ecf..0b152540f 100644
--- a/numpy/lib/tests/test_ufunclike.py
+++ b/numpy/lib/tests/test_ufunclike.py
@@ -1,9 +1,11 @@
from __future__ import division, absolute_import, print_function
+import numpy as np
import numpy.core as nx
import numpy.lib.ufunclike as ufl
from numpy.testing import (
- run_module_suite, TestCase, assert_, assert_equal, assert_array_equal
+ run_module_suite, TestCase, assert_, assert_equal, assert_array_equal,
+ assert_warns
)
@@ -61,5 +63,35 @@ class TestUfunclike(TestCase):
assert_(isinstance(f, MyArray))
assert_equal(f.metadata, 'foo')
+ # check 0d arrays don't decay to scalars
+ m0d = m[0,...]
+ m0d.metadata = 'bar'
+ f0d = ufl.fix(m0d)
+ assert_(isinstance(f0d, MyArray))
+ assert_equal(f0d.metadata, 'bar')
+
+ def test_deprecated(self):
+ # NumPy 1.13.0, 2017-04-26
+ assert_warns(DeprecationWarning, ufl.fix, [1, 2], y=nx.empty(2))
+ assert_warns(DeprecationWarning, ufl.isposinf, [1, 2], y=nx.empty(2))
+ assert_warns(DeprecationWarning, ufl.isneginf, [1, 2], y=nx.empty(2))
+
+ def test_scalar(self):
+ x = np.inf
+ actual = np.isposinf(x)
+ expected = np.True_
+ assert_equal(actual, expected)
+ assert_equal(type(actual), type(expected))
+
+ x = -3.4
+ actual = np.fix(x)
+ expected = np.float64(-3.0)
+ assert_equal(actual, expected)
+ assert_equal(type(actual), type(expected))
+
+ out = np.array(0.0)
+ actual = np.fix(x, out=out)
+ assert_(actual is out)
+
if __name__ == "__main__":
run_module_suite()