check_dict_shape

check_dict_shape(*, d, n_objects)[source]

Ensure all arrays in a dictionary have the same size on their last axis.

If n_objects is not provided, it is inferred from the first array’s last dimension. Otherwise, every array’s last dimension must match the given n_objects.

Parameters:
  • d (dict[str, ndarray] | None) – Mapping from feature/port name to numpy array where each array’s last axis is object-indexed.

  • n_objects (int | None) – Optional expected size of the last axis; if None, will be inferred.

Returns:

The validated or inferred n_objects.

Raises:

ValueError – If any array’s last dimension does not match n_objects.

Return type:

int | None