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

Function create_test_datatree

xarray/tests/conftest.py:197–247  ·  view source on GitHub ↗

Create a test datatree with this structure: Group: / │ Dimensions: (y: 3, x: 2) │ Dimensions without coordinates: y, x │ Data variables: │ a (y) int64 24B 6 7 8 │ set0 (x) int64 16B 9 10 ├── Group: /set1 │ │

()

Source from the content-addressed store, hash-verified

195
196@pytest.fixture(scope="module")
197def create_test_datatree():
198 """
199 Create a test datatree with this structure:
200
201 <xarray.DataTree>
202 Group: /
203 │ Dimensions: (y: 3, x: 2)
204 │ Dimensions without coordinates: y, x
205 │ Data variables:
206 │ a (y) int64 24B 6 7 8
207 │ set0 (x) int64 16B 9 10
208 ├── Group: /set1
209 │ │ Dimensions: ()
210 │ │ Data variables:
211 │ │ a int64 8B 0
212 │ │ b int64 8B 1
213 │ ├── Group: /set1/set1
214 │ └── Group: /set1/set2
215 ├── Group: /set2
216 │ │ Dimensions: (x: 2)
217 │ │ Dimensions without coordinates: x
218 │ │ Data variables:
219 │ │ a (x) int64 16B 2 3
220 │ │ b (x) float64 16B 0.1 0.2
221 │ └── Group: /set2/set1
222 └── Group: /set3
223
224 The structure has deliberately repeated names of tags, variables, and
225 dimensions in order to better check for bugs caused by name conflicts.
226 """
227
228 def _create_test_datatree(modify=lambda ds: ds):
229 set1_data = modify(xr.Dataset({"a": 0, "b": 1}))
230 set2_data = modify(xr.Dataset({"a": ("x", [2, 3]), "b": ("x", [0.1, 0.2])}))
231 root_data = modify(xr.Dataset({"a": ("y", [6, 7, 8]), "set0": ("x", [9, 10])}))
232
233 root = DataTree.from_dict(
234 {
235 "/": root_data,
236 "/set1": set1_data,
237 "/set1/set1": None,
238 "/set1/set2": None,
239 "/set2": set2_data,
240 "/set2/set1": None,
241 "/set3": None,
242 }
243 )
244
245 return root
246
247 return _create_test_datatree
248
249
250@pytest.fixture(scope="module")

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…