Skip to content

Commit 5fc5dd9

Browse files
committed
RF: move assert_arr_dict_equal to testing
Move testing function from parrect tests to general testing utilities.
1 parent 649eff3 commit 5fc5dd9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

nibabel/testing/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,12 @@ def runif_extra_has(test_str):
200200
"""Decorator checks to see if NIPY_EXTRA_TESTS env var contains test_str"""
201201
return skipif(test_str not in EXTRA_SET,
202202
"Skip {0} tests.".format(test_str))
203+
204+
205+
def assert_arr_dict_equal(dict1, dict2):
206+
""" Assert that two dicts are equal, where dicts contain arrays
207+
"""
208+
assert_equal(set(dict1), set(dict2))
209+
for key, value1 in dict1.items():
210+
value2 = dict2[key]
211+
assert_array_equal(value1, value2)

nibabel/tests/test_parrec.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
from nose.tools import (assert_true, assert_false, assert_raises,
2424
assert_equal)
2525

26-
from ..testing import clear_and_catch_warnings, suppress_warnings
26+
from ..testing import (clear_and_catch_warnings, suppress_warnings,
27+
assert_arr_dict_equal)
2728

2829
from .test_arrayproxy import check_mmap
2930
from . import test_spatialimages as tsi
@@ -618,13 +619,6 @@ def test_copy_on_init():
618619
assert_array_equal(HDR_DEFS['image pixel size'], 16)
619620

620621

621-
def assert_arr_dict_equal(dict1, dict2):
622-
assert_equal(set(dict1), set(dict2))
623-
for key, value1 in dict1.items():
624-
value2 = dict2[key]
625-
assert_array_equal(value1, value2)
626-
627-
628622
def assert_structarr_equal(star1, star2):
629623
# Compare structured arrays (array_equal does not work for np 1.5)
630624
assert_equal(star1.dtype, star2.dtype)

0 commit comments

Comments
 (0)