ParamValidator#
A utility class containing static methods for model parameter validation.
This class is not meant to be instantiated. It serves as a namespace
for common validation logic used by BaseModel
subclasses.
Source code in src/quantfin/models/base/validators.py
bounded(params: dict[str, float], key: str, low: float, high: float, *, model: str) -> None
staticmethod
#
Check if a parameter is within a specified inclusive range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict[str, float]
|
The dictionary of parameters to validate. |
required |
key
|
str
|
The name of the parameter to check. |
required |
low
|
float
|
The lower bound of the valid range. |
required |
high
|
float
|
The upper bound of the valid range. |
required |
model
|
str
|
The name of the model performing the validation, for error messages. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the parameter is outside the [low, high] range. |
Source code in src/quantfin/models/base/validators.py
positive(params: dict[str, float], keys: list[str], *, model: str) -> None
staticmethod
#
Check if specified parameters are strictly positive.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict[str, float]
|
The dictionary of parameters to validate. |
required |
keys
|
list[str]
|
A list of parameter names that must be positive. |
required |
model
|
str
|
The name of the model performing the validation, for error messages. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If any of the specified parameters are not strictly positive. |
Source code in src/quantfin/models/base/validators.py
require(params: dict[str, float], required: list[str], *, model: str) -> None
staticmethod
#
Check for the presence of required parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
dict[str, float]
|
The dictionary of parameters to validate. |
required |
required
|
list[str]
|
A list of parameter names that must be present in |
required |
model
|
str
|
The name of the model performing the validation, for error messages. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If any of the required parameters are missing. |