| 829 | |
| 830 | @requires_netCDF4 |
| 831 | def 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( |