zen_mapper.cover

Classes

Width_Balanced_Cover

A cover comprised of equally sized rectangular elements

Data_Balanced_Cover

A cover of 1D data with roughly equal data points per interval.

Functions

precomputed_cover(→ zen_mapper.types.CoverScheme)

A precomputed cover

rectangular_cover(centers, widths, data[, tol])

Module Contents

zen_mapper.cover.precomputed_cover(cover: zen_mapper.types.Cover) zen_mapper.types.CoverScheme

A precomputed cover

Parameters:

cover (Cover) – the precomputed cover to use

zen_mapper.cover.rectangular_cover(centers, widths, data, tol=1e-09)
class zen_mapper.cover.Width_Balanced_Cover(n_elements: numpy.typing.ArrayLike, percent_overlap: float)

A cover comprised of equally sized rectangular elements

Parameters:
  • n_elements (ArrayLike) – the number of covering elements along each dimension. If the data is dimension d this results in d^n covering elements.

  • percent_overlap (float) – a number between 0 and 1 representing the ammount of overlap between adjacent covering elements.

Raises:
  • Value Error – if n_elements < 1

  • Value Error – if percent_overlap is not in (0,1)

n_elements
percent_overlap
__call__(data)
class zen_mapper.cover.Data_Balanced_Cover(n_elements: int, percent_overlap: float)

A cover of 1D data with roughly equal data points per interval.

The cover is constructed by partitioning the sorted indices \([0, \dots, N-1]\) into intervals of approximately equal size, then mapping those index-regions back to the original data positions.

Each bin has a base size and step calculated as:

\[base\_size = \frac{N}{k - (k - 1) \times \text{overlap}} \]
\[step = base\_size \times (1 - \text{overlap}) \]

where \(k\) is n_elements.

Parameters:
  • n_elements (int) – The number of intervals (cover elements) to create. Must be $ge 1$.

  • percent_overlap (float) – The fractional overlap between adjacent intervals, $0 < text{overlap} < 1$.

n_elements

The number of cover elements.

Type:

int

percent_overlap

The fractional overlap.

Type:

float

Raises:

ValueError – If n_elements < 1 or percent_overlap is not in the range (0, 1).

Notes

A percent_overlap of 0.5 means each interval shares approximately 50% of its points with the subsequent interval.

_cover
n_elements
percent_overlap
__call__(data: numpy.typing.ArrayLike)

Partition the input data into overlapping intervals containing approximately equal numbers of points.

This method sorts the input data and applies a width-balanced cover to the indices. It then maps these index-based regions back to the original data indices to create the balanced cover.

Parameters:

data (array_like) – A 1-dimensional array of data points to be partitioned.

Returns:

A list containing the indices of the original data points belonging to each cover element. Each element in the list is an np.ndarray.

Return type:

list of ndarray

Raises:
  • ValueError – If the input data is not 1-dimensional.

  • ValueError – If the number of points in data is less than the requested n_elements.