Skip to content

Commit

Permalink
src/mlfmu/types : moved function create_fmu_signal_example() from m…
Browse files Browse the repository at this point in the history
…odule `fmu_component.py` into `fmu_component.py`. This solves a circular import issue, and feels also a more natural fit. Also made the function private (i.e. renamed to `_create_fmu_signal_example()`), as it is a helper function used only within the `fmu_component.py` module.
  • Loading branch information
ClaasRostock committed Oct 16, 2024
1 parent 121b34a commit d89871a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
20 changes: 0 additions & 20 deletions src/mlfmu/types/component_examples.py

This file was deleted.

27 changes: 23 additions & 4 deletions src/mlfmu/types/fmu_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import BaseModel, ConfigDict, StringConstraints, model_validator
from pydantic.fields import Field

from mlfmu.types.component_examples import create_fmu_signal_example
# from mlfmu.types.component_examples import _create_fmu_signal_example
from mlfmu.utils.signals import range_list_expanded
from mlfmu.utils.strings import to_camel

Expand Down Expand Up @@ -370,6 +370,25 @@ class FmiVariable:
variability: FmiVariability = FmiVariability.CONTINUOUS


def _create_fmu_signal_example() -> Variable:
"""
Create an example FMU signal variable.
Returns
-------
Variable: An instance of the Variable class representing the FMU signal variable.
"""
return Variable(
name="dis_yx",
type=FmiVariableType.REAL,
description=None,
start_value=None,
is_array=None,
length=None,
variability=None,
)


class ModelComponent(BaseModelConfig):
"""
Represents a simulation model component, used to generate the JSON schema for the model interface.
Expand Down Expand Up @@ -424,17 +443,17 @@ class ModelComponent(BaseModelConfig):
inputs: list[InputVariable] = Field(
default=[],
description="List of input signals of the simulation model.",
examples=[[create_fmu_signal_example()]],
examples=[[_create_fmu_signal_example()]],
)
outputs: list[OutputVariable] = Field(
default=[],
description="List of output signals of the simulation model.",
examples=[[create_fmu_signal_example()]],
examples=[[_create_fmu_signal_example()]],
)
parameters: list[InputVariable] = Field(
default=[],
description="List of parameter signals of the simulation model.",
examples=[[create_fmu_signal_example()]],
examples=[[_create_fmu_signal_example()]],
)
states: list[InternalState] = Field(
default=[],
Expand Down

0 comments on commit d89871a

Please sign in to comment.