Missing values#

is_missing(value: Any) bool[source]#

Return True if the value is considered missing.

Parameters:

value (Any) – The value to check.

Returns:

True if the value is missing, False otherwise.

Return type:

bool

first_not_missing(sequence: Sequence) Any | None[source]#

Return the first non-missing value from a sequence.

Parameters:

sequence (Sequence) – A sequence of values.

Returns:

The first non-missing value, or None if all values are missing.

Return type:

Optional[Any]

apply_missing_strategy(diff: ndarray, present: ndarray, nan_method: str) tuple[ndarray, ndarray][source]#

Apply the chosen missing-values strategy to the raw diff matrix.

Parameters:
  • diff (np.ndarray) – raw distance matrix for one feature, shape (n_x, n_y).

  • present (np.ndarray) – boolean mask where True means both values were non-missing.

  • nan_method (str) – one of “ignore”, “max_dist”, “raise_error”.

Returns:

Diff is adjusted distance matrix. Count_mask is int matrix of same shape, how much to add to count_present.

Return type:

tuple[np.ndarray, np.ndarray]

Raises:

ValueError – if nan_method is not recognized.