MCPcopy Index your code
hub / github.com/pydata/xarray / get_example_data

Function get_example_data

xarray/tests/test_interp.py:39–70  ·  view source on GitHub ↗
(case: int)

Source from the content-addressed store, hash-verified

37
38
39def 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

Callers 10

nd_interp_coordsFunction · 0.85
test_keywargsFunction · 0.85
test_interpolate_1dFunction · 0.85
test_interpolate_ndFunction · 0.85
test_interpolate_scalarFunction · 0.85
test_errorsFunction · 0.85

Calls 3

linspaceMethod · 0.80
sinMethod · 0.80
chunkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…