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

Function test_display_nbytes

xarray/tests/test_formatting.py:1037–1068  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1035
1036
1037def test_display_nbytes() -> None:
1038 xds = xr.Dataset(
1039 {
1040 "foo": np.arange(1200, dtype=np.int16),
1041 "bar": np.arange(111, dtype=np.int16),
1042 }
1043 )
1044
1045 # Note: int16 is used to ensure that dtype is shown in the
1046 # numpy array representation for all OSes included Windows
1047
1048 actual = repr(xds)
1049 expected = """
1050<xarray.Dataset> Size: 3kB
1051Dimensions: (foo: 1200, bar: 111)
1052Coordinates:
1053 * foo (foo) int16 2kB 0 1 2 3 4 5 6 ... 1194 1195 1196 1197 1198 1199
1054 * bar (bar) int16 222B 0 1 2 3 4 5 6 7 ... 104 105 106 107 108 109 110
1055Data variables:
1056 *empty*
1057 """.strip()
1058 assert actual == expected
1059
1060 actual = repr(xds["foo"])
1061 array_repr = repr(xds.foo.data).replace("\n ", "")
1062 expected = f"""
1063<xarray.DataArray 'foo' (foo: 1200)> Size: 2kB
1064{array_repr}
1065Coordinates:
1066 * foo (foo) int16 2kB 0 1 2 3 4 5 6 ... 1194 1195 1196 1197 1198 1199
1067""".strip()
1068 assert actual == expected
1069
1070
1071def test_array_repr_dtypes():

Callers

nothing calls this directly

Calls 3

arangeMethod · 0.80
stripMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…