diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-06-29 23:56:38 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2018-07-06 12:17:31 -0700 |
commit | 307dd76cb0fb770e07524e4cd29cd08e17edc2c3 (patch) | |
tree | e190ee007e739a9a47c34f8393e5fbd28a564a79 /numpy/lib/tests/test_function_base.py | |
parent | 739443679b50b43c34808b8fb767bac643fcd91d (diff) | |
download | numpy-307dd76cb0fb770e07524e4cd29cd08e17edc2c3.tar.gz |
BUG: Don't convert inputs to `np.float64` in digitize
This converts digitize to a pure-python function that falls back on searchsorted.
Performance doesn't really matter here anyway - if you care about performance, then you should just call searchsorted directly, rather than checking the order of the bins.
Partially fixes gh-11022
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index d2a9181db..ba5b90e8c 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1510,6 +1510,18 @@ class TestDigitize(object): assert_(not isinstance(digitize(b, a, False), A)) assert_(not isinstance(digitize(b, a, True), A)) + def test_large_integers_increasing(self): + # gh-11022 + x = 2**54 # loses precision in a float + assert_equal(np.digitize(x, [x - 1, x + 1]), 1) + + @pytest.mark.xfail( + reason="gh-11022: np.core.multiarray._monoticity loses precision") + def test_large_integers_decreasing(self): + # gh-11022 + x = 2**54 # loses precision in a float + assert_equal(np.digitize(x, [x + 1, x - 1]), 1) + class TestUnwrap(object): |