(self)
| 1455 | assert_identical(v._getitem_with_mask((slice(2), [0, 1, 2])), v) |
| 1456 | |
| 1457 | def test_isel(self): |
| 1458 | v = Variable(["time", "x"], self.d) |
| 1459 | assert_identical(v.isel(time=slice(None)), v) |
| 1460 | assert_identical(v.isel(time=0), v[0]) |
| 1461 | assert_identical(v.isel(time=slice(0, 3)), v[:3]) |
| 1462 | assert_identical(v.isel(x=0), v[:, 0]) |
| 1463 | assert_identical(v.isel(x=[0, 2]), v[:, [0, 2]]) |
| 1464 | assert_identical(v.isel(time=[]), v[[]]) |
| 1465 | with pytest.raises( |
| 1466 | ValueError, |
| 1467 | match=r"Dimensions {'not_a_dim'} do not exist. Expected one or more of " |
| 1468 | r"\('time', 'x'\)", |
| 1469 | ): |
| 1470 | v.isel(not_a_dim=0) |
| 1471 | with pytest.warns( |
| 1472 | UserWarning, |
| 1473 | match=r"Dimensions {'not_a_dim'} do not exist. Expected one or more of " |
| 1474 | r"\('time', 'x'\)", |
| 1475 | ): |
| 1476 | v.isel(not_a_dim=0, missing_dims="warn") |
| 1477 | assert_identical(v, v.isel(not_a_dim=0, missing_dims="ignore")) |
| 1478 | |
| 1479 | def test_index_0d_numpy_string(self): |
| 1480 | # regression test to verify our work around for indexing 0d strings |
nothing calls this directly
no test coverage detected