Skip to content

Commit c07688c

Browse files
committed
WIP
1 parent 06763c2 commit c07688c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

xarray/testing/strategies.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ def attrs() -> st.SearchStrategy[Mapping[Hashable, Any]]:
197197
)
198198

199199

200+
def serializable_attrs() -> st.SearchStrategy[Mapping[Hashable, Any]]:
201+
"""
202+
Generates arbitrary valid attributes dictionaries for xarray objects.
203+
204+
These are intended to be serialized, and so, are less general than the
205+
`attrs` function above.
206+
207+
Requires the hypothesis package to be installed.
208+
209+
See Also
210+
--------
211+
:ref:`testing.hypothesis`_
212+
"""
213+
return st.dictionaries(_attr_keys, _attr_values)
214+
215+
200216
@st.composite
201217
def variables(
202218
draw: st.DrawFn,

xarray/tests/test_state_machine.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def unique(draw, strategy):
4242
DIM_NAME = xrst.dimension_names(name_strategy=UNIQUE_NAME, min_dims=1, max_dims=1)
4343

4444

45+
# TODO: add datetime64[ns]
4546
def pandas_index_dtypes() -> st.SearchStrategy[np.dtype]:
4647
return (
4748
npst.integer_dtypes(endianness="<", sizes=(32, 64))
@@ -83,6 +84,7 @@ def stack(self, newname):
8384

8485
@rule()
8586
def unstack(self):
87+
# TODO: Drop duplicates
8688
self.dataset = self.dataset.unstack()
8789

8890
@rule(newname=UNIQUE_NAME)
@@ -128,5 +130,5 @@ def assert_invariants(self):
128130
_assert_internal_invariants(self.dataset, self.check_default_indexes)
129131

130132

131-
DatasetStateMachine.TestCase.settings = settings(max_examples=1000)
133+
DatasetStateMachine.TestCase.settings = settings(max_examples=1000, deadline=None)
132134
DatasetTest = DatasetStateMachine.TestCase

0 commit comments

Comments
 (0)