(self)
| 473 | buf.close() |
| 474 | |
| 475 | def test_constructor(self) -> None: |
| 476 | x1 = ("x", 2 * np.arange(100)) |
| 477 | x2 = ("x", np.arange(1000)) |
| 478 | z = (["x", "y"], np.arange(1000).reshape(100, 10)) |
| 479 | |
| 480 | with pytest.raises(ValueError, match=r"conflicting sizes"): |
| 481 | Dataset({"a": x1, "b": x2}) |
| 482 | with pytest.raises(TypeError, match=r"tuple of form"): |
| 483 | Dataset({"x": (1, 2, 3, 4, 5, 6, 7)}) |
| 484 | with pytest.raises(ValueError, match=r"already exists as a scalar"): |
| 485 | Dataset({"x": 0, "y": ("x", [1, 2, 3])}) |
| 486 | |
| 487 | # nD coordinate variable "x" sharing name with dimension |
| 488 | actual = Dataset({"a": x1, "x": z}) |
| 489 | assert "x" not in actual.xindexes |
| 490 | _assert_internal_invariants(actual, check_default_indexes=True) |
| 491 | |
| 492 | # verify handling of DataArrays |
| 493 | expected = Dataset({"x": x1, "z": z}) |
| 494 | actual = Dataset({"z": expected["z"]}) |
| 495 | assert_identical(expected, actual) |
| 496 | |
| 497 | def test_constructor_dataset_as_data_vars_raises(self) -> None: |
| 498 | ds = Dataset({"x": ("x", [1, 2, 3])}, attrs={"key": "value"}) |
nothing calls this directly
no test coverage detected