diff options
Diffstat (limited to 'numpy/ma')
-rw-r--r-- | numpy/ma/tests/test_core.py | 10 | ||||
-rw-r--r-- | numpy/ma/testutils.py | 8 |
2 files changed, 13 insertions, 5 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index e3b7b99ef..c55559001 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -1366,12 +1366,18 @@ class TestFillingValues(TestCase): fval = _check_fill_value(fill_val, ndtype) self.assertTrue(isinstance(fval, ndarray)) assert_equal(fval.item(), [-999, -12345678.9, asbytes("???")]) + #.....Using a flexible type w/ a different type shouldn't matter - fill_val = np.array((-999, -12345678.9, "???"), - dtype=[("A", int), ("B", float), ("C", "|S3")]) + # BEHAVIOR in 1.5 and earlier: match structured types by position + #fill_val = np.array((-999, -12345678.9, "???"), + # dtype=[("A", int), ("B", float), ("C", "|S3")]) + # BEHAVIOR in 1.6 and later: match structured types by name + fill_val = np.array(("???", -999, -12345678.9), + dtype=[("c", "|S3"), ("a", int), ("b", float), ]) fval = _check_fill_value(fill_val, ndtype) self.assertTrue(isinstance(fval, ndarray)) assert_equal(fval.item(), [-999, -12345678.9, asbytes("???")]) + #.....Using an object-array shouldn't matter either fill_value = np.array((-999, -12345678.9, "???"), dtype=object) fval = _check_fill_value(fill_val, ndtype) diff --git a/numpy/ma/testutils.py b/numpy/ma/testutils.py index 2b69cc4ad..235aac6e4 100644 --- a/numpy/ma/testutils.py +++ b/numpy/ma/testutils.py @@ -77,8 +77,7 @@ def assert_equal_records(a, b): def assert_equal(actual, desired, err_msg=''): - """Asserts that two items are equal. - """ + "Asserts that two items are equal." # Case #1: dictionary ..... if isinstance(desired, dict): if not isinstance(actual, dict): @@ -94,7 +93,10 @@ def assert_equal(actual, desired, err_msg=''): return _assert_equal_on_sequences(actual, desired, err_msg='') if not (isinstance(actual, ndarray) or isinstance(desired, ndarray)): msg = build_err_msg([actual, desired], err_msg,) - if not desired == actual: + try: + if not desired == actual: + raise AssertionError(msg) + except ValueError: raise AssertionError(msg) return # Case #4. arrays or equivalent |