iode
7.0.0
  • API Reference
    • WORKSPACE
      • iode.Database.names
      • iode.Database.filename
      • iode.Database.description
      • iode.Database.load
      • iode.Database.save
      • iode.Database.clear
      • iode.Database.is_subset
      • iode.Database.is_copy_subset
      • iode.Database.copy
      • iode.Database.get_names
      • iode.Database.rename
      • iode.Database.__len__
      • iode.Database.__contains__
      • iode.Database.__iter__
      • iode.Database.__getitem__
      • iode.Database.__setitem__
      • iode.Database.__delitem__
      • iode.Database.search
        • Database.search()
      • iode.Database.copy_from
      • iode.Database.merge
      • iode.Database.merge_from
      • Comments
      • Equations
      • Identities
      • Lists
      • Scalars
      • Tables
      • Variables
    • IODE OBJECTS
    • TIME
    • ESTIMATION
    • SIMULATION
    • LEC
    • REPORTS
    • PRINT
    • OTHER LIBRARIES
    • MISCELLANEOUS
    • DEPRECATED
  • Equivalence IODE Report Commands and IODE Python
  • Some test
  • IODE Python Tutorial
  • Change log
iode
  • API Reference
  • iode.Database.search
  • View page source

iode.Database.search

Note

Below, Database represents either:

  • Comments

  • Equations

  • Identities

  • Lists

  • Scalars

  • Tables

  • Variables

Database.search(self, pattern: str, word: bool = True, case_sensitive: bool = True, in_name: bool = True, in_formula: bool = True, in_text: bool = True, list_result: str = '_RES')

Return a list of all objects from the current database having a specific pattern in their names or LEC expression, comment…

The following characters in pattern have a special meaning:

  • * : any character sequence, even empty

  • ? : any character (one and only one)

  • @ : any alphanumerical char [A-Za-z0-9]

  • & : any non alphanumerical char

  • | : any alphanumeric character or none at the beginning and end of a string

  • ! : any non-alphanumeric character or none at the beginning and end of a string

  • `` : escape the next character

The Search method depends on the type of object:

  • Comments: the name and text of the comments are analyzed

  • Equations: the name and LEC form of the equations are analyzed

  • Identities: the name and LEC form of the identities are analyzed

  • Lists: the name and text of the lists are analyzed

  • Scalars: the name of the scalars is analyzed

  • Tables: the table name, titles and LEC forms are analyzed

  • Variables: the name of the variables is analyzed

Parameters:
pattern: str

string to search

word: bool, optional

Whether or not the pattern to be searched for must be a whole word and not part of a word. Default to True.

case_sensitive: bool, optional

Whether or not the search is case sensitive. Default to True.

in_name: bool, optional

Whether or not to also search in object names. Default to True.

in_formula: bool, optional

Whether or not to also search in LEC expressions (for Equations, Identities and Tables (LEC cells)). Default to True.

in_text: bool, optional

Whether or not to also search in texts (for Comments, lists, Equations (comment) and Tables (text cells)). Default to True.

list_result: str, optional

Name of the IODE list in which the resulting list of objects is saved. Default to _RES.

Returns:
list(str)

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments, equations, identities, lists, tables
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
>>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt")
>>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst")
>>> tables.load(f"{SAMPLE_DATA_DIR}/fun.tbl")
>>> # get list of comments containing 'Bruto'
>>> comments.search("Bruto")            
['GOSF', 'GOSG', 'GOSH', 'GOSH_', ..., 'VIF', 'VIG', 'YDH', 'YDH_']
>>> # get list of equations containing 'AOUC'
>>> equations.search("AOUC")
['AOUC', 'PC', 'PIF', 'PXS', 'QXAB']
>>> # get list of identities containing 'NDOMY'
>>> identities.search("NDOMY")
['LCLASS', 'LKEYN', 'UCLASS']
>>> # get list of IODE lists containing 'AOUC'
>>> lists.search("AOUC")
['COPY0', 'ENDO0', 'TOTAL0']
>>> # get list of IODE tables containing 'AOUC' in cells
>>> tables.search("AOUC")
['ANAPRIX', 'MULT1FR', 'MULT1RESU', 'T1', 'T1NIVEAU']
Previous Next

© Copyright 2024, Jean-Marc Paul, Geert Bryon, Alix Damman, Yannick Van den Abbeel.

Built with Sphinx using a theme provided by Read the Docs.