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

Method test_head

xarray/tests/test_dataarray.py:1275–1289  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1273 assert_identical(expected, selected)
1274
1275 def test_head(self) -> None:
1276 assert_equal(self.dv.isel(x=slice(5)), self.dv.head(x=5))
1277 assert_equal(self.dv.isel(x=slice(0)), self.dv.head(x=0))
1278 assert_equal(
1279 self.dv.isel({dim: slice(6) for dim in self.dv.dims}), self.dv.head(6)
1280 )
1281 assert_equal(
1282 self.dv.isel({dim: slice(5) for dim in self.dv.dims}), self.dv.head()
1283 )
1284 with pytest.raises(TypeError, match=r"either dict-like or a single int"):
1285 self.dv.head([3]) # type: ignore[arg-type]
1286 with pytest.raises(TypeError, match=r"expected integer type"):
1287 self.dv.head(x=3.1)
1288 with pytest.raises(ValueError, match=r"expected positive int"):
1289 self.dv.head(-3)
1290
1291 def test_tail(self) -> None:
1292 assert_equal(self.dv.isel(x=slice(-5, None)), self.dv.tail(x=5))

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
iselMethod · 0.45
headMethod · 0.45

Tested by

no test coverage detected