geomexp.utils package¶
Submodules¶
geomexp.utils.validation module¶
Input validation utilities for the geomexp package.
Centralised validation functions used throughout the library to enforce parameter constraints and provide consistent, informative error messages.
- geomexp.utils.validation.validate_data_array(X)[source]¶
Validate and coerce input data to a 2-D float64 array.
- Parameters:
X (
object) – Input data, coerced vianumpy.asarray().- Return type:
- Returns:
Validated array of shape
(n_samples, n_features)with dtypefloat64.- Raises:
ValueError – If the resulting array is not 2-D or has zero features.
- geomexp.utils.validation.validate_n_clusters(n_clusters, n_samples=None)[source]¶
Validate the number of clusters.
- Parameters:
- Raises:
ValueError – If
n_clusters < 1or exceedsn_samples.- Return type:
- geomexp.utils.validation.validate_positive_int(value, name)[source]¶
Validate that a parameter is a positive integer.
- Parameters:
- Raises:
TypeError – If
valueis not an integer.ValueError – If
value < 1.
- Return type:
- geomexp.utils.validation.validate_tolerance(tol)[source]¶
Validate a convergence tolerance (must be non-negative).
- Parameters:
tol (
float) – Tolerance value.- Raises:
ValueError – If
tol < 0.- Return type:
- geomexp.utils.validation.validate_index_radius(r)[source]¶
Validate the index radius constraint \(r \in [0, 1)\).
- Parameters:
r (
float) – Index radius value.- Raises:
ValueError – If
ris outside \([0, 1)\).- Return type:
- geomexp.utils.validation.validate_positive_float(value, name)[source]¶
Validate that a parameter is strictly positive.
- Parameters:
- Raises:
ValueError – If
value <= 0.- Return type:
- geomexp.utils.validation.validate_weights(weights)[source]¶
Validate a 1-D array of positive quadrature weights.
- Parameters:
weights (
object) – Weight array, coerced vianumpy.asarray().- Return type:
- Returns:
Validated 1-D
float64array.- Raises:
ValueError – If the array is not 1-D or contains non-positive entries.
- geomexp.utils.validation.validate_gram_matrix(G)[source]¶
Validate a Gram matrix (must be square, 2-D, and positive semi-definite).
Checks PSD by verifying that all eigenvalues are \(\geq -\epsilon\) where \(\epsilon\) is a small tolerance scaled by the matrix norm.
- Parameters:
G (
object) – Gram matrix, coerced vianumpy.asarray().- Return type:
- Returns:
Validated 2-D
float64array.- Raises:
ValueError – If the matrix is not square, not 2-D, or not positive semi-definite.
Module contents¶
Utility functions for the geomexp package.
- geomexp.utils.validate_data_array(X)[source]¶
Validate and coerce input data to a 2-D float64 array.
- Parameters:
X (
object) – Input data, coerced vianumpy.asarray().- Return type:
- Returns:
Validated array of shape
(n_samples, n_features)with dtypefloat64.- Raises:
ValueError – If the resulting array is not 2-D or has zero features.
- geomexp.utils.validate_gram_matrix(G)[source]¶
Validate a Gram matrix (must be square, 2-D, and positive semi-definite).
Checks PSD by verifying that all eigenvalues are \(\geq -\epsilon\) where \(\epsilon\) is a small tolerance scaled by the matrix norm.
- Parameters:
G (
object) – Gram matrix, coerced vianumpy.asarray().- Return type:
- Returns:
Validated 2-D
float64array.- Raises:
ValueError – If the matrix is not square, not 2-D, or not positive semi-definite.
- geomexp.utils.validate_index_radius(r)[source]¶
Validate the index radius constraint \(r \in [0, 1)\).
- Parameters:
r (
float) – Index radius value.- Raises:
ValueError – If
ris outside \([0, 1)\).- Return type:
- geomexp.utils.validate_n_clusters(n_clusters, n_samples=None)[source]¶
Validate the number of clusters.
- Parameters:
- Raises:
ValueError – If
n_clusters < 1or exceedsn_samples.- Return type:
- geomexp.utils.validate_positive_float(value, name)[source]¶
Validate that a parameter is strictly positive.
- Parameters:
- Raises:
ValueError – If
value <= 0.- Return type:
- geomexp.utils.validate_positive_int(value, name)[source]¶
Validate that a parameter is a positive integer.
- Parameters:
- Raises:
TypeError – If
valueis not an integer.ValueError – If
value < 1.
- Return type:
- geomexp.utils.validate_tolerance(tol)[source]¶
Validate a convergence tolerance (must be non-negative).
- Parameters:
tol (
float) – Tolerance value.- Raises:
ValueError – If
tol < 0.- Return type:
- geomexp.utils.validate_weights(weights)[source]¶
Validate a 1-D array of positive quadrature weights.
- Parameters:
weights (
object) – Weight array, coerced vianumpy.asarray().- Return type:
- Returns:
Validated 1-D
float64array.- Raises:
ValueError – If the array is not 1-D or contains non-positive entries.