def _check_level(label, expected, actual):
if SP.issparse(expected):  <EOL><INDENT>assert_(SP.issparse(actual))<EOL>assert_array_almost_equal(actual.todense(),<EOL>expected.todense(),<EOL>err_msg=label,<EOL>decimal=<NUM_LIT:5>)<EOL>return<EOL><DEDENT>assert_(types_compatible(expected, actual),<EOL>"<STR_LIT>" %<EOL>(type(expected), type(actual), label))<EOL>if not isinstance(expected,<EOL>(np.void, np.ndarray, MatlabObject)):<EOL><INDENT>assert_equal(expected, actual)<EOL>return<EOL><DEDENT>assert_(expected.shape == actual.shape,<EOL>msg='<STR_LIT>' % (expected.shape,<EOL>actual.shape,<EOL>label))<EOL>ex_dtype = expected.dtype<EOL>if ex_dtype.hasobject:  <EOL><INDENT>if isinstance(expected, MatlabObject):<EOL><INDENT>assert_equal(expected.classname, actual.classname)<EOL><DEDENT>for i, ev in enumerate(expected):<EOL><INDENT>level_label = "<STR_LIT>" % (label, i)<EOL>_check_level(level_label, ev, actual[i])<EOL><DEDENT>return<EOL><DEDENT>if ex_dtype.fields:  <EOL><INDENT>for fn in ex_dtype.fields:<EOL><INDENT>level_label = "<STR_LIT>" % (label, fn)<EOL>_check_level(level_label,<EOL>expected[fn], actual[fn])<EOL><DEDENT>return<EOL><DEDENT>if ex_dtype.type in (text_type,  <EOL>np.unicode_,<EOL>np.bool_):<EOL><INDENT>assert_equal(actual, expected, err_msg=label)<EOL>return<EOL><DEDENT>assert_array_almost_equal(actual, expected, err_msg=label, decimal=<NUM_LIT:5>)<EOL>
Check one level of a potentially nested array