rasterix.strategies

Hypothesis strategies for generating label-based indexers.

Module Contents

rasterix.strategies.pos_to_label_indexer(idx, idxr, *, use_scalar=True)[source]

Convert a positional indexer to a label-based indexer.

Parameters:
idxpd.Index

The pandas Index to use for label lookup.

idxrint | slice | np.ndarray

The positional indexer (integer, slice, or array of integers).

use_scalarbool, optional

If True, attempt to convert scalar values to Python scalars. Default is True.

Returns:
Any

The label-based indexer (scalar, slice, or array of labels).

rasterix.strategies.basic_label_indexers(draw, /, *, indexes)[source]

Generate label-based indexers by converting position indexers to labels.

This works in label space by using the coordinate Index values.

Parameters:
drawcallable

The Hypothesis draw function (automatically provided by @st.composite).

indexesIndexes

Dictionary mapping dimension names to their associated indexes

Returns:
dict[Hashable, float | slice]

Label-based indexers as a dict with keys from sizes.keys(). Values are either float (for scalar labels) or slice (for label ranges).

rasterix.strategies.outer_array_label_indexers(draw, /, *, indexes)[source]

Generate label-based outer array indexers by converting position indexers to labels.

This works in label space by using the coordinate Index values.

Parameters:
drawcallable

The Hypothesis draw function (automatically provided by @st.composite).

indexesIndexes

Dictionary mapping dimension names to their associated indexes

Returns:
dict[Hashable, np.ndarray]

Label-based indexers as a dict with keys from indexes. Values are numpy arrays of label values for each dimension.

rasterix.strategies.vectorized_label_indexers(draw, /, *, indexes, **kwargs)[source]

Generate label-based vectorized indexers by converting position indexers to labels.

This works in label space by using the coordinate Index values.

Parameters:
drawcallable

The Hypothesis draw function (automatically provided by @st.composite).

indexesIndexes

Dictionary mapping dimension names to their associated indexes

**kwargsdict

Additional keyword arguments to pass to vectorized_indexers

Returns:
dict[Hashable, xr.DataArray]

Label-based indexers as a dict with keys from indexes. Values are DataArrays of label values for each dimension.