flixopt.types ¶
Type system for dimension-aware data in flixopt.
Type aliases use suffix notation to indicate maximum dimensions. Data can have any subset of these dimensions (including scalars, which are broadcast to all dimensions).
| Suffix | Dimensions | Use Case |
|---|---|---|
_TPS | Time, Period, Scenario | Time-varying data across all dimensions |
_PS | Period, Scenario | Investment parameters (no time variation) |
_S | Scenario | Scenario-specific parameters |
| (none) | Scalar only | Single numeric values |
All dimensioned types accept: scalars (int, float), arrays (ndarray), Series (pd.Series), DataFrames (pd.DataFrame), or DataArrays (xr.DataArray).
Example
from flixopt.types import Numeric_TPS, Numeric_PS, Scalar
def create_flow(
size: Numeric_PS = None, # Scalar, array, Series, DataFrame, or DataArray
profile: Numeric_TPS = 1.0, # Time-varying data
efficiency: Scalar = 0.95, # Scalars only
): ...
# All valid:
create_flow(size=100) # Scalar broadcast
create_flow(size=np.array([100, 150])) # Period-varying
create_flow(profile=pd.DataFrame(...)) # Time + scenario
Important
Data can have any subset of specified dimensions, but cannot have more dimensions than the FlowSystem. If the FlowSystem has only time dimension, you cannot pass period or scenario data. The type hints indicate the maximum dimensions that could be used if they exist in the FlowSystem.
Attributes¶
NumericOrBool module-attribute ¶
NumericOrBool: TypeAlias = int | float | bool | integer | floating | bool_ | ndarray | Series | DataFrame | DataArray
Numeric or boolean data without dimension metadata. For internal utilities.
Numeric_TPS module-attribute ¶
Time, Period, Scenario dimensions. For time-varying data across all dimensions.
Numeric_PS module-attribute ¶
Period, Scenario dimensions. For investment parameters (e.g., size, costs).
Numeric_S module-attribute ¶
Scenario dimension. For scenario-specific parameters (e.g., discount rates).
Bool_TPS module-attribute ¶
Time, Period, Scenario dimensions. For time-varying binary flags/constraints.
Bool_PS module-attribute ¶
Period, Scenario dimensions. For period-specific binary decisions.
Bool_S module-attribute ¶
Scenario dimension. For scenario-specific binary flags.
Effect_TPS module-attribute ¶
Time, Period, Scenario dimensions. Dict mapping effect names to values. For time-varying effects (costs, emissions). Use Effect_TPS | Numeric_TPS to accept single values.
Effect_PS module-attribute ¶
Period, Scenario dimensions. Dict mapping effect names to values. For period-specific effects (investment costs). Use Effect_PS | Numeric_PS to accept single values.
Effect_S module-attribute ¶
Scenario dimension. Dict mapping effect names to values. For scenario-specific effects (carbon prices). Use Effect_S | Numeric_S to accept single values.
Scalar module-attribute ¶
Scalar numeric values only. Not converted to DataArray (unlike dimensioned types).