Skip to content

Commit f268c1e

Browse files
committed
RF: refactor test to work on numpy 1.5
Structured array comparisons with ``assert_array_compare`` fail for numpy 1.5; use a more manual comparison method.
1 parent 9e074f7 commit f268c1e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nibabel/tests/test_parrec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ def assert_arr_dict_equal(dict1, dict2):
423423
assert_array_equal(value1, value2)
424424

425425

426+
def assert_structarr_equal(star1, star2):
427+
# Compare structured arrays (array_equal does not work for np 1.5)
428+
assert_equal(star1.dtype, star2.dtype)
429+
for name in star1.dtype.names:
430+
assert_array_equal(star1[name], star2[name])
431+
432+
426433
def test_header_copy():
427434
# Test header copying
428435
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
@@ -434,7 +441,7 @@ def assert_copy_ok(hdr1, hdr2):
434441
assert_false(hdr1.general_info is hdr2.general_info)
435442
assert_arr_dict_equal(hdr1.general_info, hdr2.general_info)
436443
assert_false(hdr1.image_defs is hdr2.image_defs)
437-
assert_array_equal(hdr1.image_defs, hdr2.image_defs)
444+
assert_structarr_equal(hdr1.image_defs, hdr2.image_defs)
438445

439446
assert_copy_ok(hdr, hdr2)
440447
assert_false(hdr.permit_truncated)

0 commit comments

Comments
 (0)