| 645 | assert_identical(expected["foo"], unpickled) |
| 646 | |
| 647 | def test_dataset_caching(self) -> None: |
| 648 | expected = Dataset({"foo": ("x", [5, 6, 7])}) |
| 649 | with self.roundtrip(expected) as actual: |
| 650 | assert isinstance(actual.foo.variable._data, indexing.MemoryCachedArray) |
| 651 | assert not actual.foo.variable._in_memory |
| 652 | _ = actual.foo.values # cache |
| 653 | assert actual.foo.variable._in_memory |
| 654 | |
| 655 | with self.roundtrip(expected, open_kwargs={"cache": False}) as actual: |
| 656 | assert isinstance(actual.foo.variable._data, indexing.CopyOnWriteArray) |
| 657 | assert not actual.foo.variable._in_memory |
| 658 | _ = actual.foo.values # no caching |
| 659 | assert not actual.foo.variable._in_memory |
| 660 | |
| 661 | def test_roundtrip_None_variable(self) -> None: |
| 662 | expected = Dataset({None: (("x", "y"), [[0, 1], [2, 3]])}) |