def assert_equal(actual,desired,err_msg='<STR_LIT>',verbose=True):
if isinstance(desired, dict):<EOL><INDENT>if not isinstance(actual, dict) :<EOL><INDENT>raise AssertionError(repr(type(actual)))<EOL><DEDENT>assert_equal(len(actual), len(desired), err_msg, verbose)<EOL>for k, i in desired.items():<EOL><INDENT>if k not in actual :<EOL><INDENT>raise AssertionError(repr(k))<EOL><DEDENT>assert_equal(actual[k], desired[k], '<STR_LIT>' % (k, err_msg), verbose)<EOL><DEDENT>return<EOL><DEDENT>if isinstance(desired, (list, tuple)) and isinstance(actual, (list, tuple)):<EOL><INDENT>assert_equal(len(actual), len(desired), err_msg, verbose)<EOL>for k in range(len(desired)):<EOL><INDENT>assert_equal(actual[k], desired[k], '<STR_LIT>' % (k, err_msg), verbose)<EOL><DEDENT>return<EOL><DEDENT>from numpy.core import ndarray, isscalar, signbit<EOL>from numpy.lib import iscomplexobj, real, imag<EOL>if isinstance(actual, ndarray) or isinstance(desired, ndarray):<EOL><INDENT>return assert_array_equal(actual, desired, err_msg, verbose)<EOL><DEDENT>msg = build_err_msg([actual, desired], err_msg, verbose=verbose)<EOL>try:<EOL><INDENT>usecomplex = iscomplexobj(actual) or iscomplexobj(desired)<EOL><DEDENT>except ValueError:<EOL><INDENT>usecomplex = False<EOL><DEDENT>if usecomplex:<EOL><INDENT>if iscomplexobj(actual):<EOL><INDENT>actualr = real(actual)<EOL>actuali = imag(actual)<EOL><DEDENT>else:<EOL><INDENT>actualr = actual<EOL>actuali = <NUM_LIT:0><EOL><DEDENT>if iscomplexobj(desired):<EOL><INDENT>desiredr = real(desired)<EOL>desiredi = imag(desired)<EOL><DEDENT>else:<EOL><INDENT>desiredr = desired<EOL>desiredi = <NUM_LIT:0><EOL><DEDENT>try:<EOL><INDENT>assert_equal(actualr, desiredr)<EOL>assert_equal(actuali, desiredi)<EOL><DEDENT>except AssertionError:<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if isscalar(desired) != isscalar(actual):<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT>if not (gisfinite(desired) and gisfinite(actual)):<EOL><INDENT>isdesnan = gisnan(desired)<EOL>isactnan = gisnan(actual)<EOL>if isdesnan or isactnan:<EOL><INDENT>if not (isdesnan and isactnan):<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not desired == actual:<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT><DEDENT>return<EOL><DEDENT>elif desired == <NUM_LIT:0> and actual == <NUM_LIT:0>:<EOL><INDENT>if not signbit(desired) == signbit(actual):<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT><DEDENT><DEDENT>except (TypeError, ValueError, NotImplementedError):<EOL><INDENT>pass<EOL><DEDENT>if not (desired == actual):<EOL><INDENT>raise AssertionError(msg)<EOL><DEDENT>
Raises an AssertionError if two objects are not equal.

Given two objects (scalars, lists, tuples, dictionaries or numpy arrays),
check that all elements of these objects are equal. An exception is raised
at the first conflicting values.

Parameters
----------
actual : array_like
    The object to check.
desired : array_like
    The expected object.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.

Raises
------
AssertionError
    If actual and desired are not equal.

Examples
--------
>>> np.testing.assert_equal([4,5], [4,6])
...
<type 'exceptions.AssertionError'>:
Items are not equal:
item=1
 ACTUAL: 5
 DESIRED: 6