diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-07-13 15:53:34 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-07-13 15:58:35 +0100 |
commit | 575a48e0da892d447a4d884f024df82c567e6f3f (patch) | |
tree | da75c57b0dc74642999addc06d317aedf8780069 /numpy/lib/tests/test_function_base.py | |
parent | 3484c83f8c65123df2d95078c56deed296c5f2b8 (diff) | |
download | numpy-575a48e0da892d447a4d884f024df82c567e6f3f.tar.gz |
BUG: float16 is promoted to float64 by gradient
This isn't the case for `diff`
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index f6d4b6111..2f766471f 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -926,6 +926,12 @@ class TestGradient(TestCase): assert_array_equal(gradient(x), dx) assert_(dx.dtype == np.dtype('timedelta64[D]')) + def test_inexact_dtypes(self): + for dt in [np.float16, np.float32, np.float64]: + # dtypes should not be promoted in a different way to what diff does + x = np.array([1, 2, 3], dtype=dt) + assert_equal(gradient(x).dtype, np.diff(x).dtype) + def test_values(self): # needs at least 2 points for edge_order ==1 gradient(np.arange(2), edge_order=1) |