MCPcopy
hub / github.com/pydata/xarray / create_dataset

Method create_dataset

xarray/tests/test_backends_api.py:185–198  ·  view source on GitHub ↗

Return a dataset with a variable with the given shape and preferred chunks.

(self, shape, pref_chunks)

Source from the content-addressed store, hash-verified

183 var_name = "data"
184
185 def create_dataset(self, shape, pref_chunks):
186 """Return a dataset with a variable with the given shape and preferred chunks."""
187 dims = tuple(f"dim_{idx}" for idx in range(len(shape)))
188 return xr.Dataset(
189 {
190 self.var_name: xr.Variable(
191 dims,
192 np.empty(shape, dtype=np.dtype("V1")),
193 encoding={
194 "preferred_chunks": dict(zip(dims, pref_chunks, strict=True))
195 },
196 )
197 }
198 )
199
200 def check_dataset(self, initial, final, expected_chunks):
201 assert_identical(initial, final)

Callers 6

test_honor_chunksMethod · 0.95
test_split_chunksMethod · 0.95
test_join_chunksMethod · 0.95

Calls 2

emptyMethod · 0.80
dtypeMethod · 0.45

Tested by

no test coverage detected