Types¶
pyconvexity.core.types
¶
Core data types for PyConvexity.
These types mirror the Rust implementation while providing Python-specific enhancements and better type safety.
StaticValue
¶
Represents a static (non-time-varying) attribute value.
Mirrors the Rust StaticValue enum while providing Python conveniences. Supports float, int, bool, and string values with proper type conversion.
to_json() -> str
¶
Return raw value as JSON to match Rust serialization format.
Rust stores: 123.45, 42, true, "hello" Not: {"Float": 123.45}, {"Integer": 42}, etc.
data_type() -> str
¶
Get data type name - mirrors Rust implementation
as_f64() -> float
¶
Convert to float, mirroring Rust implementation
value() -> Union[float, int, bool, str]
¶
Get the raw Python value
Timeseries
dataclass
¶
Efficient timeseries data structure matching the new Rust implementation.
Stores values as a flat array for maximum performance, matching the unified Rust Timeseries struct.
get_value(index: int) -> Optional[float]
¶
Get value at specific index.
get_range(start: int, end: int) -> List[float]
¶
Get a range of values efficiently.
sample(max_points: int) -> Timeseries
¶
Apply sampling if the timeseries is too large.
slice(start_index: int, end_index: int) -> Timeseries
¶
Apply range filtering.
TimeseriesMetadata
dataclass
¶
Metadata about a timeseries without loading the full data.
Mirrors Rust TimeseriesMetadata struct.
TimePeriod
dataclass
¶
Represents a time period in the network's time axis.
Mirrors Rust TimePeriod structure.
TimeseriesValidationResult
dataclass
¶
Result of validating timeseries alignment with network time periods.
Mirrors Rust TimeseriesValidationResult.
ValidationRule
dataclass
¶
Validation rule for component attributes.
Mirrors Rust ValidationRule with all fields.
AttributeValue
¶
Represents either a static value or timeseries data for a component attribute.
Uses efficient Timeseries format for optimal performance. Mirrors Rust AttributeValue enum.
static(value: StaticValue) -> AttributeValue
classmethod
¶
Create a static attribute value
timeseries(timeseries: Timeseries) -> AttributeValue
classmethod
¶
Create a timeseries attribute value (new format)
is_static() -> bool
¶
Check if this is a static value
is_timeseries() -> bool
¶
Check if this is a timeseries value
as_timeseries() -> Optional[Timeseries]
¶
Get the timeseries data in new format
Component
dataclass
¶
Represents a component in the energy system model (single network per database).
Mirrors Rust Component struct.
Network
dataclass
¶
Represents a network/model in the system.
Enhanced version of network information with additional metadata.
CreateComponentRequest
dataclass
¶
Request structure for creating a new component (single network per database).
Mirrors Rust CreateComponentRequest.
CreateNetworkRequest
dataclass
¶
Request structure for creating a new network.
Mirrors Rust CreateNetworkRequest.
Carrier
dataclass
¶
Represents an energy carrier (e.g., electricity, heat, gas).
Scenario
dataclass
¶
Represents a scenario within a network.