(self)
| 1908 | assert actual.x.encoding["zlib"] |
| 1909 | |
| 1910 | def test_dump_and_open_encodings(self) -> None: |
| 1911 | # Create a netCDF file with explicit time units |
| 1912 | # and make sure it makes it into the encodings |
| 1913 | # and survives a round trip |
| 1914 | with create_tmp_file() as tmp_file: |
| 1915 | with nc4.Dataset(tmp_file, "w") as ds: |
| 1916 | ds.createDimension("time", size=10) |
| 1917 | ds.createVariable("time", np.int32, dimensions=("time",)) |
| 1918 | units = "days since 1999-01-01" |
| 1919 | ds.variables["time"].setncattr("units", units) |
| 1920 | ds.variables["time"][:] = np.arange(10) + 4 |
| 1921 | |
| 1922 | with open_dataset(tmp_file) as xarray_dataset: |
| 1923 | with create_tmp_file() as tmp_file2: |
| 1924 | xarray_dataset.to_netcdf(tmp_file2) |
| 1925 | with nc4.Dataset(tmp_file2, "r") as ds: |
| 1926 | assert ds.variables["time"].getncattr("units") == units |
| 1927 | assert_array_equal(ds.variables["time"], np.arange(10) + 4) |
| 1928 | |
| 1929 | def test_compression_encoding_legacy(self) -> None: |
| 1930 | data = create_test_data() |
nothing calls this directly
no test coverage detected