validate_callable_signature¶
yohou.utils.weighting.validate_callable_signature(time_weight)
¶
Validate that callable has valid signature for time weighting.
Checks that the callable accepts either 1 parameter (global weighting) or 2 parameters (panel-aware weighting). Raises ValueError for invalid signatures.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
time_weight
|
Callable
|
Callable to validate. Must have signature (time: pl.Series) -> pl.Series or (time: pl.Series, group_name: str) -> pl.Series. |
required |
Returns¶
| Type | Description |
|---|---|
int
|
Number of parameters (1 or 2) for valid signatures. |
Raises¶
| Type | Description |
|---|---|
ValueError
|
If callable signature is invalid (not 1 or 2 parameters). |
See Also¶
exponential_decay_weight: Exponential decay weights for recent times.linear_decay_weight: Linear decay weights for recent times.seasonal_emphasis_weight: Weights emphasizing seasonal positions.compose_weights: Compose multiple weight functions by multiplication.BaseReductionForecaster: Reduction forecaster supporting time_weight.
Examples¶
>>> def global_weight(time):
... return time * 0 + 1
>>> validate_callable_signature(global_weight)
1
>>> def panel_weight(time, group_name):
... return time * 0 + 1
>>> validate_callable_signature(panel_weight)
2