xarray.testing.strategies.unique_subset_of(objs, *, min_size=0, max_size=None)#

Return a strategy which generates a unique subset of the given objects.

Each entry in the output subset will be unique (if input was a sequence) or have a unique key (if it was a mapping).

Requires the hypothesis package to be installed.

  • objs (Union[Sequence[Hashable], Mapping[Hashable, Any]]) – Objects from which to sample to produce the subset.

  • min_size (int, optional) – Minimum size of the returned subset. Default is 0.

  • max_size (int, optional) – Maximum size of the returned subset. Default is the full length of the input. If set to 0 the result will be an empty mapping.


unique_subset_strategy – Strategy generating subset of the input.


>>> unique_subset_of({"x": 2, "y": 3}).example()  
{'y': 3}
>>> unique_subset_of(["x", "y"]).example()