larray.Session.equals

Session.equals(other, rtol=0, atol=0, nans_equal=False) bool[source]

Test if all elements (groups, axes and arrays) of the current session are equal to those of another session.

Parameters
otherSession

Session to compare with.

rtolfloat or int, optional

The relative tolerance parameter (see Notes). Defaults to 0.

atolfloat or int, optional

The absolute tolerance parameter (see Notes). Defaults to 0.

nans_equalboolean, optional

Whether to consider NaN values at the same positions in the two arrays as equal. By default, an array containing NaN values is never equal to another array, even if that other array also contains NaN values at the same positions. The reason is that a NaN value is different from anything, including itself. Defaults to True.

Returns
True if elements of both sessions are all equal, False otherwise.

Notes

Metadata is ignored.

For finite values, equals uses the following equation to test whether two arrays are equal:

absolute(array1 - array2) <= (atol + rtol * absolute(array2))

Examples

>>> a = Axis('a=a0..a2')
>>> a01 = a['a0,a1'] >> 'a01'
>>> s1 = Session({'a': a, 'a01': a01, 'arr1': ndtest(2), 'arr2': ndtest((2, 2))})
>>> s2 = Session({'a': a, 'a01': a01, 'arr1': ndtest(2), 'arr2': ndtest((2, 2))})

Identical sessions

>>> s1.equals(s2)
True

Different value(s) between two arrays

>>> s2.arr1['a1'] = 0
>>> s1.equals(s2)
False

Test equality between two arrays within a given tolerance range. Return True if absolute(s1.arr1 - s2.arr1) <= (atol + rtol * absolute(s2.arr1)).

>>> s1.arr1 = Array([6., 8.], "a=a0,a1")
>>> s2.arr1 = Array([5.999, 8.001], "a=a0,a1")
>>> s1.equals(s2)
False
>>> s1.equals(s2, atol=0.01)
True
>>> s1.equals(s2, rtol=0.01)
True

Different label(s)

>>> s2.arr2 = ndtest("b=b0,b1; a=a0,a1")
>>> s2.a = Axis('a=a0,a1')
>>> s1.equals(s2)
False

Extra/missing axis(es), group(s), array(s)

>>> s2.arr3 = ndtest((3, 3))
>>> del s2.a
>>> s1.equals(s2)
False