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

Method stack

properties/test_index_manipulation.py:130–150  ·  view source on GitHub ↗
(self, data, create_index)

Source from the content-addressed store, hash-verified

128 @rule(data=st.data(), create_index=st.booleans())
129 @precondition(lambda self: bool(self.indexed_dims))
130 def stack(self, data, create_index):
131 newname = self._draw_unique_name(data)
132 oldnames = data.draw(
133 st.lists(
134 st.sampled_from(self.indexed_dims),
135 min_size=1,
136 max_size=3 if create_index else None,
137 unique=True,
138 )
139 )
140 note(f"> stacking {oldnames} as {newname}")
141 self.dataset = self.dataset.stack(
142 {newname: oldnames}, create_index=create_index
143 )
144
145 if create_index:
146 self.multi_indexed_dims += [newname]
147
148 # if create_index is False, then we just drop these
149 for dim in oldnames:
150 del self.indexed_dims[self.indexed_dims.index(dim)]
151
152 @rule(data=st.data())
153 @precondition(lambda self: bool(self.multi_indexed_dims))

Callers

nothing calls this directly

Calls 2

_draw_unique_nameMethod · 0.95
indexMethod · 0.45

Tested by

no test coverage detected