Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[ModelicaSystem] more type hints fixes / cleanups
  • Loading branch information
syntron committed Nov 10, 2025
commit 7db5e97c3553a278f35a933c47335e2571e5ac4f
23 changes: 15 additions & 8 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def __init__(

self._quantities: list[dict[str, Any]] = []
self._params: dict[str, str] = {} # even numerical values are stored as str
self._inputs: dict[str, list | None] = {}
self._inputs: dict[str, list[tuple[float, float]]] = {}
# _outputs values are str before simulate(), but they can be
# np.float64 after simulate().
self._outputs: dict[str, Any] = {}
Expand All @@ -386,8 +386,15 @@ def __init__(
self._simulate_options: dict[str, str] = {}
self._override_variables: dict[str, str] = {}
self._simulate_options_override: dict[str, str] = {}
self._linearization_options = {'startTime': 0.0, 'stopTime': 1.0, 'stepSize': 0.002, 'tolerance': 1e-8}
self._optimization_options = self._linearization_options | {'numberOfIntervals': 500}
self._linearization_options: dict[str, str | float] = {
'startTime': 0.0,
'stopTime': 1.0,
'stepSize': 0.002,
'tolerance': 1e-8,
}
self._optimization_options = self._linearization_options | {
'numberOfIntervals': 500,
}
self._linearized_inputs: list[str] = [] # linearization input list
self._linearized_outputs: list[str] = [] # linearization output list
self._linearized_states: list[str] = [] # linearization states list
Expand Down Expand Up @@ -797,7 +804,7 @@ def getParameters(
def getInputs(
self,
names: Optional[str | list[str]] = None,
) -> dict[str, list[tuple[numbers.Real]]] | list[tuple[numbers.Real]]:
) -> dict[str, list[tuple[float, float]]] | list[list[tuple[float, float]]]:
"""Get values of input signals.

Args:
Expand Down Expand Up @@ -942,7 +949,7 @@ def getSimulationOptions(
def getLinearizationOptions(
self,
names: Optional[str | list[str]] = None,
) -> dict[str, str | numbers.Real] | list[str | numbers.Real]:
) -> dict[str, str | float] | list[str | float]:
"""Get simulation options used for linearization.

Args:
Expand Down Expand Up @@ -980,7 +987,7 @@ def getLinearizationOptions(
def getOptimizationOptions(
self,
names: Optional[str | list[str]] = None,
) -> dict[str, str | numbers.Real] | list[str | numbers.Real]:
) -> dict[str, str | float] | list[str | float]:
"""Get simulation options used for optimization.

Args:
Expand Down Expand Up @@ -1789,9 +1796,9 @@ def linearize(
continue

# type: ignore
value = ast.literal_eval(body_part.value)
value_ast = ast.literal_eval(body_part.value)

linear_data[target] = value
linear_data[target] = value_ast
except (AttributeError, IndexError, ValueError, SyntaxError, TypeError) as ex:
raise ModelicaSystemError(f"Error parsing linearization file {linear_file}!") from ex

Expand Down