cosapp.utils.find_variables

Functions

find_system_properties(system[, include_const])

Returns system properties, defined either as class properties (with @property decorator), or with System.add_property.

find_variable_names(system, includes, excludes)

Generate the list of requested variable names, given inclusion and exclusion criteria.

find_variables(system, includes, excludes[, ...])

Generate the dictionary (name, value) of variables whose names match inclusion and exclusion criteria.

get_attributes(obj)

Returns non-callable members of an object

make_wishlist(wishlist[, name])

cosapp.utils.find_variables.find_system_properties(system, include_const=False) Set[str][source]

Returns system properties, defined either as class properties (with @property decorator), or with System.add_property. The latter are excluded if optional argument include_const is False (default).

Parameters:
  • [cosapp.systems.System] (- system) – System of interest

  • [bool (- include_const) – Defines if read-only properties defined with System.add_property will be accepted or not.. Default: False.

  • optional] – Defines if read-only properties defined with System.add_property will be accepted or not.. Default: False.

Returns:

Set of property names.

Return type:

  • set[str]

cosapp.utils.find_variables.find_variable_names(system: cosapp.systems.System, includes: str | ~typing.List[str], excludes: str | ~typing.List[str], advanced_filter: ~typing.Callable[[~typing.Any], bool] = <function <lambda>>, inputs: bool = True, outputs: bool = True, include_const: bool = False) List[str][source]

Generate the list of requested variable names, given inclusion and exclusion criteria.

Matching variable names are returned in alphabetical order.

Parameters:
  • system (cosapp.systems.System) – Object that owns the variables searched.

  • includes (str or List[str]) – Variables matching these patterns will be included.

  • excludes (str or List[str]) – Variables matching these patterns will be excluded.

  • advanced_filter (Callable[[Any], bool]) – Function taking the variable as input and returning an acceptance criteria (True if variable is valid).

  • inputs (bool) – Defines if input variables will be accepted or not.

  • outputs (bool) – Defines if output variables will be accepted or not.

  • include_const (bool) – Defines if read-only properties defined with System.add_property will be accepted or not.

Returns:

  • list[str] – Variable names in system matching the requested includes/excludes patterns.

  • .. note:: – Inward and outward variables will appear without the prefix inwards. or outwards.. This functions returns the sorted keys of the dictionary returned by find_variables.

cosapp.utils.find_variables.find_variables(system: cosapp.systems.System, includes: str | ~typing.List[str], excludes: str | ~typing.List[str], advanced_filter: ~typing.Callable[[~typing.Any], bool] = <function <lambda>>, inputs: bool = True, outputs: bool = True, include_const: bool = False) Dict[str, Any][source]

Generate the dictionary (name, value) of variables whose names match inclusion and exclusion criteria.

Parameters:
  • system (cosapp.systems.System) – Object that owns the variables searched.

  • includes (str or List[str]) – Variables matching these patterns will be included.

  • excludes (str or List[str]) – Variables matching these patterns will be excluded.

  • advanced_filter (Callable[[Any], bool]) – Function taking the variable as input and returning an acceptance criteria (True if variable is valid).

  • inputs (bool) – Defines if input variables will be accepted or not.

  • outputs (bool) – Defines if output variables will be accepted or not.

  • include_const (bool) – Defines if read-only properties defined with System.add_property will be accepted or not.

Returns:

  • dict[str, Any] – Dictionary (name, value) of matches.

  • .. note:: – Inward and outward variables will appear without the prefix inwards. or outwards..

cosapp.utils.find_variables.get_attributes(obj) Set[str][source]

Returns non-callable members of an object

cosapp.utils.find_variables.make_wishlist(wishlist: str | List[str], name='wishlist') List[str][source]