Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/referencing-0.36.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Revathyvenugopal162 authored Jan 31, 2025
2 parents d62d776 + 939f088 commit 399fa1f
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 97 deletions.
1 change: 1 addition & 0 deletions doc/changelog/27.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Documentation only changes
2 changes: 1 addition & 1 deletion doc/source/api/language/declarations/common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commonly used by other classes.
SwanItem class
--------------

The :class:`SwanItem` is the top level class for all constructs.
The :class:`SwanItem` is the top-level class for all constructs.

.. autoclass:: SwanItem
:no-show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/language/expressions/forward.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Forward Expression
Forward expression
==================

.. currentmodule:: ansys.scadeone.core.swan
Expand Down
8 changes: 4 additions & 4 deletions doc/source/user_guide/modeler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A *ScadeOne* instance is created with the following code:
.. literalinclude:: quad_flight_control.py
:lines: 14

where :py:attr:`install_dir` is the location of Scade One installation and it could take a string or a
where :py:attr:`install_dir` is the location of Scade One installation and it could take a string or
a :py:class:`pathlib.Path` object as value. The *app* object is then used to access to projects.


Expand Down Expand Up @@ -111,7 +111,7 @@ Here are some examples:
item is found.

In the following example, the :py:meth:`ansys.scadeone.core.model.Model.find_declaration`
is used to filter a specific operator. In that case, the search stops (and the load)
is used to filter a specific operator. In that case, the search (and the load) stops
when the requested operator is found. As we will use Swan constructs, we need to import
their definitions:

Expand All @@ -120,7 +120,7 @@ their definitions:
# Module defining all Swan-related classes, see below
import ansys.scadeone.core.swan as swan
Here an example to filter declarations to get specific operator:
Here is an example to filter declarations to get specific operator:

.. literalinclude:: quad_flight_control.py
:lines: 39-47
Expand All @@ -133,7 +133,7 @@ The model content represents the structure of the Swan program, starting with
the declarations: types, constants, groups, sensors, operators, and signatures.

For an operator or a signature, one can access to the input and output flows
and to the body for operator. Then from the body, one can access to the content of diagrams, equations, etc.
and to the body for operator. Then, from the body, one can access to the content of diagrams, equations, etc.

All Swan language constructs are represented by classes from the
:py:mod:`ansys.scadeone.core.swan` module. The section :ref:`ref_swan_api` describes
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/scadeone/core/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, text: str, **kwargs) -> None:
self._text = text

def exists(self) -> bool:
"""Always returns True."""
"""Always return True."""
return True

def content(self) -> str:
Expand Down Expand Up @@ -198,7 +198,7 @@ def extract_version(source: str) -> Union[dict, None]:
Returns
-------
Union[dict, None]
Either the version information as a dict, or None if no version found.
Either the version information as a dictionary, or None if no version found.
"""
m = re.match(r"^--\s*version\s+(?P<ver>.*)$", source, re.MULTILINE)
if m:
Expand Down
34 changes: 17 additions & 17 deletions src/ansys/scadeone/core/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):
self._parser = None

def configure(self, project: "project.IProject"):
"""Configures model with project as owner. The configuration
"""Configure model with project as owner. The configuration
associate the project and the model and prepare internal data to
store module bodies and interfaces.
Expand Down Expand Up @@ -95,7 +95,7 @@ def _load_source(self, swan: SwanFile) -> S.Module:

@property
def all_modules_loaded(self) -> True:
"""Returns True when all Swan modules have been loaded."""
"""Return True when all Swan modules have been loaded."""
return all(self._modules.values())

@property
Expand All @@ -104,7 +104,7 @@ def modules(self) -> Generator[S.Module, None, None]:
return (module for module in self._modules.values() if module)

def _get_module(self, name: str, search_module_body: bool) -> Union[S.Module, None]:
"""Returns module body of name 'name'"""
"""Return module body of name 'name'"""
for swan_code, swan_object in self._modules.items():
if swan_object is None:
swan_object = self._load_source(swan_code)
Expand All @@ -116,23 +116,23 @@ def _get_module(self, name: str, search_module_body: bool) -> Union[S.Module, No
return None

def get_module_body(self, name: str) -> Union[S.ModuleBody, None]:
"""Returns module body of name 'name'"""
"""Return module body of name 'name'"""
if body := self._get_module(name, True):
return cast(S.ModuleBody, body)
return None

def get_module_interface(self, name: str) -> Union[S.ModuleInterface, None]:
"""Returns module interface of name 'name'"""
"""Return module interface of name 'name'"""
if interface := self._get_module(name, False):
return cast(S.ModuleInterface, interface)
return None

def get_module_from_pathid(self, pathid: str, module: S.Module) -> Union[S.Module, None]:
"""Return the :py:class:`Module` instance for a given *pathid*
"""Return the :py:class:`Module` instance for a given *pathid*.
A *path* is of the form *[ID ::]+ ID*, where the last ID is the object
name, and the "ID::ID...::" is the module path.
If the *pathid* has no path part (reduced to ID), return *module*
If the *pathid* has no path part (reduced to ID), return *module*.
Parameters
----------
Expand Down Expand Up @@ -179,48 +179,48 @@ def get_module_from_pathid(self, pathid: str, module: S.Module) -> Union[S.Modul

@property
def types(self) -> Generator[S.TypeDecl, None, None]:
"""Returns a generator on type declarations."""
"""Return a generator on type declarations."""
for decls in self.filter_declarations(lambda x: isinstance(x, S.TypeDeclarations)):
for decl in cast(S.TypeDeclarations, decls).types:
yield decl

@property
def sensors(self) -> Generator[S.SensorDecl, None, None]:
"""Returns a generator on sensor declarations."""
"""Return a generator on sensor declarations."""
for decls in self.filter_declarations(lambda x: isinstance(x, S.SensorDeclarations)):
for decl in cast(S.SensorDeclarations, decls).sensors:
yield decl

@property
def constants(self) -> Generator[S.ConstDecl, None, None]:
"""Returns a generator on constant declarations."""
"""Return a generator on constant declarations."""
for decls in self.filter_declarations(lambda x: isinstance(x, S.ConstDeclarations)):
for decl in cast(S.ConstDeclarations, decls).constants:
yield decl

@property
def groups(self) -> Generator[S.GroupDecl, None, None]:
"""Returns a generator on group declarations."""
"""Return a generator on group declarations."""
for decls in self.filter_declarations(lambda x: isinstance(x, S.GroupDeclarations)):
for decl in cast(S.GroupDeclarations, decls).groups:
yield decl

@property
def operators(self) -> Generator[S.Operator, None, None]:
"""Returns a generator on operator declarations."""
"""Return a generator on operator declarations."""
for decl in self.filter_declarations(lambda x: isinstance(x, S.Operator)):
yield decl

@property
def signatures(self) -> Generator[S.Signature, None, None]:
"""Returns a generator on operator signature declarations."""
"""Return a generator on operator signature declarations."""
for decl in self.filter_declarations(
lambda x: isinstance(x, S.Signature) and not isinstance(x, S.Operator)
):
yield decl

def load_module(self, name: str):
"""Loads module by name
"""Load module by name
Parameters
----------
Expand All @@ -238,7 +238,7 @@ def load_module(self, name: str):
self._load_source(swan)

def load_all_modules(self):
"""Loads systematically all modules."""
"""Load systematically all modules."""
for swan in self._modules.keys():
self._load_source(swan)

Expand All @@ -257,7 +257,7 @@ def declarations(self) -> Generator[S.GlobalDeclaration, None, None]:
yield decl

def filter_declarations(self, filter_fn) -> Generator[S.GlobalDeclaration, None, None]:
"""Returns declarations matched by a filter.
"""Return declarations matched by a filter.
Parameters
----------
Expand All @@ -272,7 +272,7 @@ def filter_declarations(self, filter_fn) -> Generator[S.GlobalDeclaration, None,
return filter(filter_fn, self.declarations)

def find_declaration(self, predicate_fn) -> Union[S.GlobalDeclaration, None]:
"""Finds a declaration for which predicate_fn returns True.
"""Find a declaration for which predicate_fn returns True.
Parameters
----------
Expand Down
8 changes: 4 additions & 4 deletions src/ansys/scadeone/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def directory(self) -> Union[Path, None]:
return None

def _get_swan_sources(self) -> List[SwanFile]:
"""Returns Swan files of project.
"""Return Swan files of project.
Returns
-------
Expand All @@ -99,9 +99,9 @@ def _get_swan_sources(self) -> List[SwanFile]:
return sources

def swan_sources(self, all=False) -> List[SwanFile]:
"""Returns all Swan sources from project.
"""Return all Swan sources from project.
If all is True, includes also sources from project dependencies.
If all is True, include also sources from project dependencies.
Returns
-------
Expand Down Expand Up @@ -149,7 +149,7 @@ def check_path(path: str):
def dependencies(self, all=False) -> List[Self]:
"""Project dependencies as list of Projects.
If all is True, includes recursively dependencies of dependencies.
If all is True, include recursively dependencies of dependencies.
A dependency occurs only once.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/scadeone/core/scadeone.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def projects(self) -> List[Project]:
return self._projects

def subst_in_path(self, path: str) -> str:
"""Substitutes $(SCADE_ONE_LIBRARIES_DIR) in path.
"""Substitute $(SCADE_ONE_LIBRARIES_DIR) in path.
if :py:attr:`ScadeOne.install_dir` is None, no change is made.
"""
Expand Down
20 changes: 10 additions & 10 deletions src/ansys/scadeone/core/svc/fmu/fmu_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ def __init__(

@property
def direction(self) -> str:
"""Returns the direction ('input' or 'output') of the variable"""
"""Return the direction ('input' or 'output') of the variable"""
if self._direction is None:
self._direction = "output" if self._var_kind == "output" else "input"
return self._direction

@property
def type_name(self) -> str:
"""Returns the generated type name of the variable"""
"""Return the generated type name of the variable"""
return self._type_elem["name"]

@property
def type_kind(self) -> str:
"""Returns the name of the FMU type corresponding to generated type of a given variable."""
"""Return the name of the FMU type corresponding to generated type of a given variable."""

def fmu_ty_of_scade_ty(ty: dict) -> str:
type_name = ty["name"]
Expand Down Expand Up @@ -138,12 +138,12 @@ def fmu_ty_of_scade_ty(ty: dict) -> str:

@property
def oper_path(self) -> str:
"""Returns the Scade One path for the exported operator owning the variable."""
"""Return the Scade One path for the exported operator owning the variable."""
return self._fmu.oper_path + "/"

@property
def xml_description(self) -> str:
"""Returns the description of the variable used by the FMI model description"""
"""Return the description of the variable used by the FMI model description"""
if self._xml_description is None:
if self._var_kind == "sensor":
self._xml_description = self._sc_path
Expand All @@ -153,7 +153,7 @@ def xml_description(self) -> str:

@property
def xml_name(self) -> str:
"""Returns the name of the variable used by the FMI model description"""
"""Return the name of the variable used by the FMI model description"""

def _replace_brackets(match):
# Find all digits in the match and join them with commas
Expand All @@ -171,7 +171,7 @@ def _replace_brackets(match):

def get_default_value(self, xml=True) -> str:
"""
Returns the default value corresponding to FMU type of a given variable.
Return the default value corresponding to FMU type of a given variable.
Expected types are 'Real', 'Integer' and 'Boolean'.
"""
if self.type_kind == "Real":
Expand All @@ -186,7 +186,7 @@ def get_default_value(self, xml=True) -> str:
@staticmethod
def paths_of_param(sc_path: str, c_path: str, code_type: dict) -> List[Tuple[str, str, dict]]:
"""
Returns the list of paths of scalar variables corresponding
Return the list of paths of scalar variables corresponding
to the variable named `name` of type `ty` (of type `mapping.C.Type`).
"""
var_list = []
Expand Down Expand Up @@ -222,7 +222,7 @@ def model_vars_of_param(
fmu: "FMU_Export", v: Union[GC.ModelVariable, GC.ModelSensor], var_kind: str
) -> List["ModelVar"]:
"""
Returns the list of variables corresponding
Return the list of variables corresponding
to the given model variable (input or output) or sensor.
"""
if isinstance(v, GC.ModelVariable):
Expand Down Expand Up @@ -835,7 +835,7 @@ def _build_zip(self, with_sources: bool):

def generate(self, kind: str, outdir: Union[str, os.PathLike], period: float = 0.02) -> None:
"""
Generates the FMI 2.0 XML and C file according to SCADE generated code.
Generate the FMI 2.0 XML and C file according to SCADE generated code.
- kind: FMI kind ('ME' for Model Exchange, 'CS' for Co-Simulation).
- outdir: directory where the files are generated.
Expand Down
Loading

0 comments on commit 399fa1f

Please sign in to comment.