xarray.testing.assert_equal#
- xarray.testing.assert_equal(a, b, from_root=True)[source]#
Like
numpy.testing.assert_array_equal()
, but for xarray objects.Raises an AssertionError if two objects are not equal. This will match data values, dimensions and coordinates, but not names or attributes (except for Dataset objects for which the variable names must match). Arrays with NaN in the same location are considered equal.
For DataTree objects, assert_equal is mapped over all Datasets on each node, with the DataTrees being equal if both are isomorphic and the corresponding Datasets at each node are themselves equal.
- Parameters:
a (
xarray.Dataset
,xarray.DataArray
,xarray.Variable
,xarray.Coordinates
) โ or xarray.core.datatree.DataTree. The first object to compare.b (
xarray.Dataset
,xarray.DataArray
,xarray.Variable
,xarray.Coordinates
) โ or xarray.core.datatree.DataTree. The second object to compare.from_root (
bool
, optional, defaultis True
) โ Only used when comparing DataTree objects. Indicates whether or not to first traverse to the root of the trees before checking for isomorphism. If a & b have no parents then this has no effect.
See also
assert_identical
,assert_allclose
,Dataset.equals
,DataArray.equals
,numpy.testing.assert_array_equal