(case: int)
| 37 | |
| 38 | |
| 39 | def get_example_data(case: int) -> xr.DataArray: |
| 40 | if case == 0: |
| 41 | # 2D |
| 42 | x = np.linspace(0, 1, 100) |
| 43 | y = np.linspace(0, 0.1, 30) |
| 44 | return xr.DataArray( |
| 45 | np.sin(x[:, np.newaxis]) * np.cos(y), |
| 46 | dims=["x", "y"], |
| 47 | coords={"x": x, "y": y, "x2": ("x", x**2)}, |
| 48 | ) |
| 49 | elif case == 1: |
| 50 | # 2D chunked single dim |
| 51 | return get_example_data(0).chunk({"y": 3}) |
| 52 | elif case == 2: |
| 53 | # 2D chunked both dims |
| 54 | return get_example_data(0).chunk({"x": 25, "y": 3}) |
| 55 | elif case == 3: |
| 56 | # 3D |
| 57 | x = np.linspace(0, 1, 100) |
| 58 | y = np.linspace(0, 0.1, 30) |
| 59 | z = np.linspace(0.1, 0.2, 10) |
| 60 | return xr.DataArray( |
| 61 | np.sin(x[:, np.newaxis, np.newaxis]) * np.cos(y[:, np.newaxis]) * z, |
| 62 | dims=["x", "y", "z"], |
| 63 | coords={"x": x, "y": y, "x2": ("x", x**2), "z": z}, |
| 64 | ) |
| 65 | elif case == 4: |
| 66 | # 3D chunked single dim |
| 67 | # chunksize=5 lets us check whether we rechunk to 1 with quintic |
| 68 | return get_example_data(3).chunk({"z": 5}) |
| 69 | else: |
| 70 | raise ValueError("case must be 1-4") |
| 71 | |
| 72 | |
| 73 | @pytest.fixture |
no test coverage detected
searching dependent graphs…