MCPcopy Create free account
hub / github.com/pydata/xarray / setup

Method setup

asv_bench/benchmarks/unstacking.py:34–49  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

32
33class UnstackingSparse(Unstacking):
34 def setup(self, *args, **kwargs):
35 requires_sparse()
36
37 import sparse
38
39 data = sparse.random((500, 1000), random_state=0, fill_value=0)
40 self.da_full = xr.DataArray(data, dims=list("ab")).stack(flat_dim=[...])
41 self.da_missing = self.da_full[:-1]
42
43 mindex = pd.MultiIndex.from_arrays([np.arange(100), np.arange(100)])
44 self.da_eye_2d = xr.DataArray(np.ones((100,)), dims="z", coords={"z": mindex})
45 self.da_eye_3d = xr.DataArray(
46 np.ones((100, 50)),
47 dims=("z", "foo"),
48 coords={"z": mindex, "foo": np.arange(50)},
49 )
50
51 def time_unstack_to_sparse_2d(self):
52 self.da_eye_2d.unstack(sparse=True)

Callers

nothing calls this directly

Calls 3

requires_sparseFunction · 0.85
arangeMethod · 0.80
stackMethod · 0.45

Tested by

no test coverage detected