-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b366c91
commit 822f014
Showing
23 changed files
with
2,865 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# coding: utf-8 | ||
|
||
# flake8: noqa | ||
""" | ||
PowerSystemModels | ||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
The version of the OpenAPI document: 1.0.0 | ||
Generated by OpenAPI Generator (https://openapi-generator.tech) | ||
Do not edit the class manually. | ||
""" # noqa: E501 | ||
|
||
# import models into model package | ||
from openapi_client.models.average_rate_curve import AverageRateCurve | ||
from openapi_client.models.average_rate_curve_function_data import AverageRateCurveFunctionData | ||
from openapi_client.models.cost_curve import CostCurve | ||
from openapi_client.models.cost_curve_value_curve import CostCurveValueCurve | ||
from openapi_client.models.fuel_curve import FuelCurve | ||
from openapi_client.models.fuel_curve_fuel_cost import FuelCurveFuelCost | ||
from openapi_client.models.incremental_curve import IncrementalCurve | ||
from openapi_client.models.incremental_curve_function_data import IncrementalCurveFunctionData | ||
from openapi_client.models.input_output_curve import InputOutputCurve | ||
from openapi_client.models.input_output_curve_function_data import InputOutputCurveFunctionData | ||
from openapi_client.models.linear_function_data import LinearFunctionData | ||
from openapi_client.models.min_max import MinMax | ||
from openapi_client.models.piecewise_linear_data import PiecewiseLinearData | ||
from openapi_client.models.piecewise_linear_data_points_inner import PiecewiseLinearDataPointsInner | ||
from openapi_client.models.piecewise_step_data import PiecewiseStepData | ||
from openapi_client.models.quadratic_function_data import QuadraticFunctionData | ||
from openapi_client.models.start_up_stages import StartUpStages | ||
from openapi_client.models.thermal_standard import ThermalStandard | ||
from openapi_client.models.thermal_standard_operation_cost import ThermalStandardOperationCost | ||
from openapi_client.models.thermal_standard_operation_cost_start_up import ThermalStandardOperationCostStartUp | ||
from openapi_client.models.thermal_standard_operation_cost_variable import ( | ||
ThermalStandardOperationCostVariable, | ||
) | ||
from openapi_client.models.up_down import UpDown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
PowerSystemModels | ||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
The version of the OpenAPI document: 1.0.0 | ||
Generated by OpenAPI Generator (https://openapi-generator.tech) | ||
Do not edit the class manually. | ||
""" # noqa: E501 | ||
|
||
from __future__ import annotations | ||
import pprint | ||
import re # noqa: F401 | ||
import json | ||
|
||
from infrasys import Component | ||
|
||
from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator | ||
from typing import Any, ClassVar, Dict, List, Optional, Union | ||
Check failure on line 22 in src/r2x/models/generated/average_rate_curve.py GitHub Actions / ruffRuff (UP035)
|
||
from openapi_client.models.average_rate_curve_function_data import AverageRateCurveFunctionData | ||
from typing import Optional, Set | ||
Check failure on line 24 in src/r2x/models/generated/average_rate_curve.py GitHub Actions / ruffRuff (UP035)
|
||
from typing_extensions import Self | ||
|
||
|
||
class AverageRateCurve(Component): | ||
""" | ||
AverageRateCurve | ||
""" # noqa: E501 | ||
|
||
curve_type: Optional[StrictStr] = None | ||
function_data: AverageRateCurveFunctionData | ||
initial_input: Optional[Union[StrictFloat, StrictInt]] = None | ||
input_at_zero: Optional[Union[StrictFloat, StrictInt]] = None | ||
__properties: ClassVar[List[str]] = ["curve_type", "function_data", "initial_input", "input_at_zero"] | ||
|
||
@field_validator("curve_type") | ||
def curve_type_validate_enum(cls, value): | ||
"""Validates the enum""" | ||
if value is None: | ||
return value | ||
|
||
if value not in set(["AVERAGE_RATE"]): | ||
raise ValueError("must be one of enum values ('AVERAGE_RATE')") | ||
return value | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
validate_assignment=True, | ||
protected_namespaces=(), | ||
) | ||
|
||
def to_str(self) -> str: | ||
"""Returns the string representation of the model using alias""" | ||
return pprint.pformat(self.model_dump(by_alias=True)) | ||
|
||
def to_json(self) -> str: | ||
"""Returns the JSON representation of the model using alias""" | ||
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead | ||
return json.dumps(self.to_dict()) | ||
|
||
@classmethod | ||
def from_json(cls, json_str: str) -> Optional[Self]: | ||
"""Create an instance of AverageRateCurve from a JSON string""" | ||
return cls.from_dict(json.loads(json_str)) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
"""Return the dictionary representation of the model using alias. | ||
This has the following differences from calling pydantic's | ||
`self.model_dump(by_alias=True)`: | ||
* `None` is only added to the output dict for nullable fields that | ||
were set at model initialization. Other fields with value `None` | ||
are ignored. | ||
""" | ||
excluded_fields: Set[str] = set([]) | ||
|
||
_dict = self.model_dump( | ||
by_alias=True, | ||
exclude=excluded_fields, | ||
exclude_none=True, | ||
) | ||
# override the default output from pydantic by calling `to_dict()` of function_data | ||
if self.function_data: | ||
_dict["function_data"] = self.function_data.to_dict() | ||
return _dict | ||
|
||
@classmethod | ||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: | ||
"""Create an instance of AverageRateCurve from a dict""" | ||
if obj is None: | ||
return None | ||
|
||
if not isinstance(obj, dict): | ||
return cls.model_validate(obj) | ||
|
||
_obj = cls.model_validate( | ||
{ | ||
"curve_type": obj.get("curve_type"), | ||
"function_data": AverageRateCurveFunctionData.from_dict(obj["function_data"]) | ||
if obj.get("function_data") is not None | ||
else None, | ||
"initial_input": obj.get("initial_input"), | ||
"input_at_zero": obj.get("input_at_zero"), | ||
} | ||
) | ||
return _obj |
169 changes: 169 additions & 0 deletions
169
src/r2x/models/generated/average_rate_curve_function_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
# coding: utf-8 | ||
|
||
""" | ||
PowerSystemModels | ||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
The version of the OpenAPI document: 1.0.0 | ||
Generated by OpenAPI Generator (https://openapi-generator.tech) | ||
Do not edit the class manually. | ||
""" # noqa: E501 | ||
|
||
from __future__ import annotations | ||
import json | ||
import pprint | ||
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator | ||
from typing import Any, List, Optional | ||
from openapi_client.models.linear_function_data import LinearFunctionData | ||
from openapi_client.models.piecewise_linear_data import PiecewiseLinearData | ||
from openapi_client.models.quadratic_function_data import QuadraticFunctionData | ||
from pydantic import StrictStr, Field | ||
from typing import Union, List, Set, Optional, Dict | ||
from typing_extensions import Literal, Self | ||
|
||
AVERAGERATECURVEFUNCTIONDATA_ONE_OF_SCHEMAS = [ | ||
"LinearFunctionData", | ||
"PiecewiseLinearData", | ||
"QuadraticFunctionData", | ||
] | ||
|
||
|
||
class AverageRateCurveFunctionData(BaseModel): | ||
""" | ||
AverageRateCurveFunctionData | ||
""" | ||
|
||
# data type: LinearFunctionData | ||
oneof_schema_1_validator: Optional[LinearFunctionData] = None | ||
# data type: QuadraticFunctionData | ||
oneof_schema_2_validator: Optional[QuadraticFunctionData] = None | ||
# data type: PiecewiseLinearData | ||
oneof_schema_3_validator: Optional[PiecewiseLinearData] = None | ||
actual_instance: Optional[Union[LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]] = None | ||
one_of_schemas: Set[str] = {"LinearFunctionData", "PiecewiseLinearData", "QuadraticFunctionData"} | ||
|
||
model_config = ConfigDict( | ||
validate_assignment=True, | ||
protected_namespaces=(), | ||
) | ||
|
||
discriminator_value_class_map: Dict[str, str] = {} | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
if args: | ||
if len(args) > 1: | ||
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") | ||
if kwargs: | ||
raise ValueError("If a position argument is used, keyword arguments cannot be used.") | ||
super().__init__(actual_instance=args[0]) | ||
else: | ||
super().__init__(**kwargs) | ||
|
||
@field_validator("actual_instance") | ||
def actual_instance_must_validate_oneof(cls, v): | ||
instance = AverageRateCurveFunctionData.model_construct() | ||
error_messages = [] | ||
match = 0 | ||
# validate data type: LinearFunctionData | ||
if not isinstance(v, LinearFunctionData): | ||
error_messages.append(f"Error! Input type `{type(v)}` is not `LinearFunctionData`") | ||
else: | ||
match += 1 | ||
# validate data type: QuadraticFunctionData | ||
if not isinstance(v, QuadraticFunctionData): | ||
error_messages.append(f"Error! Input type `{type(v)}` is not `QuadraticFunctionData`") | ||
else: | ||
match += 1 | ||
# validate data type: PiecewiseLinearData | ||
if not isinstance(v, PiecewiseLinearData): | ||
error_messages.append(f"Error! Input type `{type(v)}` is not `PiecewiseLinearData`") | ||
else: | ||
match += 1 | ||
if match > 1: | ||
# more than 1 match | ||
raise ValueError( | ||
"Multiple matches found when setting `actual_instance` in AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
elif match == 0: | ||
# no match | ||
raise ValueError( | ||
"No match found when setting `actual_instance` in AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
else: | ||
return v | ||
|
||
@classmethod | ||
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: | ||
return cls.from_json(json.dumps(obj)) | ||
|
||
@classmethod | ||
def from_json(cls, json_str: str) -> Self: | ||
"""Returns the object represented by the json string""" | ||
instance = cls.model_construct() | ||
error_messages = [] | ||
match = 0 | ||
|
||
# deserialize data into LinearFunctionData | ||
try: | ||
instance.actual_instance = LinearFunctionData.from_json(json_str) | ||
match += 1 | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
# deserialize data into QuadraticFunctionData | ||
try: | ||
instance.actual_instance = QuadraticFunctionData.from_json(json_str) | ||
match += 1 | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
# deserialize data into PiecewiseLinearData | ||
try: | ||
instance.actual_instance = PiecewiseLinearData.from_json(json_str) | ||
match += 1 | ||
except (ValidationError, ValueError) as e: | ||
error_messages.append(str(e)) | ||
|
||
if match > 1: | ||
# more than 1 match | ||
raise ValueError( | ||
"Multiple matches found when deserializing the JSON string into AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
elif match == 0: | ||
# no match | ||
raise ValueError( | ||
"No match found when deserializing the JSON string into AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " | ||
+ ", ".join(error_messages) | ||
) | ||
else: | ||
return instance | ||
|
||
def to_json(self) -> str: | ||
"""Returns the JSON representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return "null" | ||
|
||
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): | ||
return self.actual_instance.to_json() | ||
else: | ||
return json.dumps(self.actual_instance) | ||
|
||
def to_dict( | ||
self, | ||
) -> Optional[Union[Dict[str, Any], LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]]: | ||
"""Returns the dict representation of the actual instance""" | ||
if self.actual_instance is None: | ||
return None | ||
|
||
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): | ||
return self.actual_instance.to_dict() | ||
else: | ||
# primitive type | ||
return self.actual_instance | ||
|
||
def to_str(self) -> str: | ||
"""Returns the string representation of the actual instance""" | ||
return pprint.pformat(self.model_dump()) |
Oops, something went wrong.