tsdat.testing

Utility functions used in tsdat tests.

Functions

assert_close

Thin wrapper around xarray.assert_allclose.

Function Descriptions

tsdat.testing.assert_close(a: xarray.Dataset, b: xarray.Dataset, check_attrs: bool = True, check_fill_value: bool = True, **kwargs: Any) None[source]

Thin wrapper around xarray.assert_allclose.

Also checks dataset and variable attrs. Removes global attributes that are allowed to be different, which are currently just the ‘history’ attribute and the ‘code_version’ attribute. Also handles some obscure edge cases for variable attributes.

Parameters
  • a (xr.Dataset) – The first dataset to compare.

  • b (xr.Dataset) – The second dataset to compare.

  • check_attrs (bool) – Check global and variable attributes in addition to the data. Defaults to True.

  • check_fill_value (bool) – Check the _FillValue attribute. This is a special case because xarray moves the _FillValue from a variable’s attributes to its encoding upon saving the dataset. Defaults to True.