diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-06-12 15:15:28 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-06-12 15:27:44 -0600 |
commit | f60c553e6c92447d71fc960faf81bdeb9c54bbd6 (patch) | |
tree | 0d364045a8672d8bc9a9ef94c02fb50c81c89b49 /numpy | |
parent | 8f172ddbb90357e80bafa2cd7df4b307ce15600b (diff) | |
download | numpy-f60c553e6c92447d71fc960faf81bdeb9c54bbd6.tar.gz |
TST: Test that true_divide works for float inputs and dtype=np.float.
This was failing due to the check for matching loops not searching
through all available loops, rather ending with int8 inputs and float
output, which in turn would fail casting.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_ufunc.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py index 699a1b2ea..b9412684d 100644 --- a/numpy/core/tests/test_ufunc.py +++ b/numpy/core/tests/test_ufunc.py @@ -342,6 +342,16 @@ class TestUfunc(TestCase): np.add(a, 0.5, sig=('i4', 'i4', 'i4'), out=b, casting='unsafe') assert_equal(b, [0, 0, 1]) + def test_true_divide(self): + # True_divide has a non uniform signature, see #3484. + # This also tests type_tuple_type_resolver. + a = np.full(5, 12.5) + b = np.full(5, 10.0) + tgt = np.full(5, 1.25) + assert_almost_equal(np.true_divide(a, b, dtype=np.float64), tgt) + assert_almost_equal(np.true_divide(a, b, dtype=np.float32), tgt) + assert_raises(TypeError, np.true_divide, a, b, dtype=np.int) + def test_sum_stability(self): a = np.ones(500, dtype=np.float32) assert_almost_equal((a / 10.).sum() - a.size / 10., 0, 4) |