diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-08-19 13:39:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 13:39:51 +0300 |
commit | 05a88ad2aacd16f8e38a44fece6588f6ee840a32 (patch) | |
tree | 271faeb5160242100e123296905fc72d4056e62d /numpy/lib/tests/test_function_base.py | |
parent | 0dc55882a976630d832ebebdb58350d9c26205fe (diff) | |
parent | 26734efdb1c8ee269bb97acc22b587027a5a3f88 (diff) | |
download | numpy-05a88ad2aacd16f8e38a44fece6588f6ee840a32.tar.gz |
Merge pull request #17058 from BvB93/trim_zeros2
MAINT: Revert boolean casting back to elementwise comparisons in `trim_zeros`
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 635fe1432..34a395ee4 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1169,7 +1169,7 @@ class TestTrimZeros: a = np.array([0, 0, 1, 0, 2, 3, 4, 0]) b = a.astype(float) c = a.astype(complex) - d = np.array([None, [], 1, False, 'b', 3.0, range(4), b''], dtype=object) + d = a.astype(object) def values(self): attr_names = ('a', 'b', 'c', 'd') @@ -1208,6 +1208,22 @@ class TestTrimZeros: res = trim_zeros(arr) assert_array_equal(arr, res) + @pytest.mark.parametrize( + 'arr', + [np.array([0, 2**62, 0]), + np.array([0, 2**63, 0]), + np.array([0, 2**64, 0])] + ) + def test_overflow(self, arr): + slc = np.s_[1:2] + res = trim_zeros(arr) + assert_array_equal(res, arr[slc]) + + def test_no_trim(self): + arr = np.array([None, 1, None]) + res = trim_zeros(arr) + assert_array_equal(arr, res) + class TestExtins: |