MCPcopy Index your code
hub / github.com/pydata/xarray / test_repr_file_collapsed

Function test_repr_file_collapsed

xarray/tests/test_formatting.py:831–858  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

829
830@requires_netCDF4
831def test_repr_file_collapsed(tmp_path) -> None:
832 arr_to_store = xr.DataArray(np.arange(300, dtype=np.int64), dims="test")
833 arr_to_store.to_netcdf(tmp_path / "test.nc", engine="netcdf4")
834
835 with (
836 xr.open_dataarray(tmp_path / "test.nc") as arr,
837 xr.set_options(display_expand_data=False),
838 ):
839 actual = repr(arr)
840 expected = dedent(
841 """\
842 <xarray.DataArray (test: 300)> Size: 2kB
843 [300 values with dtype=int64]
844 Dimensions without coordinates: test"""
845 )
846
847 assert actual == expected
848
849 arr_loaded = arr.compute()
850 actual = arr_loaded.__repr__()
851 expected = dedent(
852 """\
853 <xarray.DataArray (test: 300)> Size: 2kB
854 0 1 2 3 4 5 6 7 8 9 10 11 12 ... 288 289 290 291 292 293 294 295 296 297 298 299
855 Dimensions without coordinates: test"""
856 )
857
858 assert actual == expected
859
860
861@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

to_netcdfMethod · 0.95
arangeMethod · 0.80
computeMethod · 0.45
__repr__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…