xcdat.compare_datasets

xcdat.compare_datasets#

xcdat.compare_datasets(ds1, ds2)[source]#

Compares the keys and values of two datasets.

This utility function is especially useful for debugging tests that involve comparing two Dataset objects for being identical or equal.

Checks include:

  • Unique keys - keys that exist only in one of the two datasets.

  • Non-identical - keys whose values have the same dimension, coordinates, values, name, attributes, and attributes on all coordinates.

  • Non-equal keys - keys whose values have the same dimension, coordinates, and values, but not necessarily the same attributes. Key values that are non-equal will also be non-identical.

Parameters:
  • ds1 (xr.Dataset) – The first Dataset.

  • ds2 (xr.Dataset) – The second Dataset.

Returns:

Dict[str, Union[List[str]]] – A dictionary mapping unique, non-identical, and non-equal keys in both Datasets.