primap2.csg.StrategyDefinition#
- class primap2.csg.StrategyDefinition(strategies: list[tuple[dict[Hashable, str | list[str]], FillingStrategyModel]])[source]#
Defines filling strategies for a single timeseries.
- Attributes:
- strategies
List of mappings from a timeseries selector to a filling strategy. When a timeseries will be used to fill missing data, the list will be checked from the start, and the first matching TimeseriesSelector determines the FillingStrategy. Example: [({“source”: [“FAOSTAT”, “UNFCCC]}, StraightStrategy()), ({}, GlobalStrategy())] Note that the strategy can depend on fixed dimensions as well as priority dimensions. In practice, it is usually a good idea to include a default strategy using the empty selector {} which matches everything. It has to be the last entry - since it matches everything, all entries behind it will be ignored.
Methods
check_dimensions
(ds)Raise an error if the strategy definition uses the wrong dimensions.
find_strategies
(fill_ts)Yields all strategies to use for the timeseries, in configured order.
find_strategy
(fill_ts)Find the strategy to use for the given filling timeseries.
limit
(dim, value)Limit this strategy definition to strategies applicable with the limit.
match_single_dim
(*, selector, dim, value)Check if a literal value in one dimension can match the selector.
- __init__(strategies: list[tuple[dict[Hashable, str | list[str]], FillingStrategyModel]]) None #
Method generated by attrs for class StrategyDefinition.
Methods
__init__
(strategies)Method generated by attrs for class StrategyDefinition.
check_dimensions
(ds)Raise an error if the strategy definition uses the wrong dimensions.
find_strategies
(fill_ts)Yields all strategies to use for the timeseries, in configured order.
find_strategy
(fill_ts)Find the strategy to use for the given filling timeseries.
limit
(dim, value)Limit this strategy definition to strategies applicable with the limit.
match_single_dim
(*, selector, dim, value)Check if a literal value in one dimension can match the selector.
Attributes
strategies