(self)
| 2783 | @requires_dask |
| 2784 | @pytest.mark.filterwarnings("ignore:The specified chunks separate:UserWarning") |
| 2785 | def test_manual_chunk(self) -> None: |
| 2786 | original = create_test_data().chunk({"dim1": 3, "dim2": 4, "dim3": 3}) |
| 2787 | |
| 2788 | # Using chunks = None should return non-chunked arrays |
| 2789 | open_kwargs: dict[str, Any] = {"chunks": None} |
| 2790 | with self.roundtrip(original, open_kwargs=open_kwargs) as actual: |
| 2791 | for k, v in actual.variables.items(): |
| 2792 | # only index variables should be in memory |
| 2793 | assert v._in_memory == (k in actual.dims) |
| 2794 | # there should be no chunks |
| 2795 | assert v.chunks is None |
| 2796 | |
| 2797 | # uniform arrays |
| 2798 | for i in range(2, 6): |
| 2799 | rechunked = original.chunk(chunks=i) |
| 2800 | open_kwargs = {"chunks": i} |
| 2801 | with self.roundtrip(original, open_kwargs=open_kwargs) as actual: |
| 2802 | for k, v in actual.variables.items(): |
| 2803 | # only index variables should be in memory |
| 2804 | assert v._in_memory == (k in actual.dims) |
| 2805 | # chunk size should be the same as rechunked |
| 2806 | assert v.chunks == rechunked[k].chunks |
| 2807 | |
| 2808 | chunks = {"dim1": 2, "dim2": 3, "dim3": 5} |
| 2809 | rechunked = original.chunk(chunks=chunks) |
| 2810 | |
| 2811 | open_kwargs = { |
| 2812 | "chunks": chunks, |
| 2813 | "backend_kwargs": {"overwrite_encoded_chunks": True}, |
| 2814 | } |
| 2815 | with self.roundtrip(original, open_kwargs=open_kwargs) as actual: |
| 2816 | for k, v in actual.variables.items(): |
| 2817 | assert v.chunks == rechunked[k].chunks |
| 2818 | |
| 2819 | with self.roundtrip(actual) as auto: |
| 2820 | # encoding should have changed |
| 2821 | for k, v in actual.variables.items(): |
| 2822 | assert v.chunks == rechunked[k].chunks |
| 2823 | |
| 2824 | assert_identical(actual, auto) |
| 2825 | assert_identical(actual.load(), auto.load()) |
| 2826 | |
| 2827 | def test_unlimited_dims_encoding_is_ignored(self) -> None: |
| 2828 | ds = Dataset({"x": np.arange(10)}) |
nothing calls this directly
no test coverage detected