MCPcopy
hub / github.com/pydata/xarray / test_cmp_local_file

Method test_cmp_local_file

xarray/tests/test_backends.py:6593–6626  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6591 yield actual, expected
6592
6593 def test_cmp_local_file(self) -> None:
6594 with self.create_datasets() as (actual, expected):
6595 assert_equal(actual, expected)
6596
6597 # global attributes should be global attributes on the dataset
6598 assert "NC_GLOBAL" not in actual.attrs
6599 assert "history" in actual.attrs
6600
6601 # we don't check attributes exactly with assertDatasetIdentical()
6602 # because the test DAP server seems to insert some extra
6603 # attributes not found in the netCDF file.
6604 assert actual.attrs.keys() == expected.attrs.keys()
6605
6606 with self.create_datasets() as (actual, expected):
6607 assert_equal(actual[{"l": 2}], expected[{"l": 2}])
6608
6609 with self.create_datasets() as (actual, expected):
6610 # always return arrays and not scalars
6611 # scalars will be promoted to unicode for numpy >= 2.3.0
6612 assert_equal(actual.isel(i=[0], j=[-1]), expected.isel(i=[0], j=[-1]))
6613
6614 with self.create_datasets() as (actual, expected):
6615 assert_equal(actual.isel(j=slice(1, 2)), expected.isel(j=slice(1, 2)))
6616
6617 with self.create_datasets() as (actual, expected):
6618 indexers = {"i": [1, 0, 0], "j": [1, 2, 0, 1]}
6619 assert_equal(actual.isel(**indexers), expected.isel(**indexers))
6620
6621 with self.create_datasets() as (actual, expected):
6622 indexers2 = {
6623 "i": DataArray([0, 1, 0], dims="a"),
6624 "j": DataArray([0, 2, 1], dims="a"),
6625 }
6626 assert_equal(actual.isel(**indexers2), expected.isel(**indexers2))
6627
6628 def test_compatible_to_netcdf(self) -> None:
6629 # make sure it can be saved as a netcdf

Callers

nothing calls this directly

Calls 5

create_datasetsMethod · 0.95
assert_equalFunction · 0.90
DataArrayClass · 0.90
keysMethod · 0.80
iselMethod · 0.45

Tested by

no test coverage detected