diff options
author | wim glenn <wim.glenn@melbourneit.com.au> | 2015-06-15 22:42:23 +1000 |
---|---|---|
committer | wim glenn <wim.glenn@melbourneit.com.au> | 2015-06-15 22:42:23 +1000 |
commit | 3dd9a5dd7e30a05e97b3671976eee87564370ac1 (patch) | |
tree | a50a9eb71d4a828c6d7bc277be32aba2ff4ec9d3 /numpy | |
parent | 8b447baab0932c7bd5cf89aba3e9e2197e4be735 (diff) | |
download | numpy-3dd9a5dd7e30a05e97b3671976eee87564370ac1.tar.gz |
tests for removing explicit size check
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index a9281a644..6f45972c3 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -5731,14 +5731,47 @@ class TestArrayPriority(TestCase): assert_(isinstance(f(b, a), self.Other), msg) -class TestEmptyStringArray(TestCase): +class TestBytestringArrayNonzero(TestCase): def test_empty_bstring_array_is_falsey(self): self.assertFalse(np.array([''], dtype=np.str)) + def test_whitespace_bstring_array_is_falsey(self): + a = np.array(['spam'], dtype=np.str) + a[0] = ' \0\0' + self.assertFalse(a) + + def test_all_null_bstring_array_is_falsey(self): + a = np.array(['spam'], dtype=np.str) + a[0] = '\0\0\0\0' + self.assertFalse(a) + + def test_null_inside_bstring_array_is_truthy(self): + a = np.array(['spam'], dtype=np.str) + a[0] = ' \0 \0' + self.assertTrue(a) + + +class TestUnicodeArrayNonzero(TestCase): + def test_empty_ustring_array_is_falsey(self): self.assertFalse(np.array([''], dtype=np.unicode)) + def test_whitespace_ustring_array_is_falsey(self): + a = np.array(['eggs'], dtype=np.unicode) + a[0] = ' \0\0' + self.assertFalse(a) + + def test_all_null_ustring_array_is_falsey(self): + a = np.array(['eggs'], dtype=np.unicode) + a[0] = '\0\0\0\0' + self.assertFalse(a) + + def test_null_inside_ustring_array_is_truthy(self): + a = np.array(['eggs'], dtype=np.unicode) + a[0] = ' \0 \0' + self.assertTrue(a) + if __name__ == "__main__": run_module_suite() |