iode.Equations.get_names

Equations.get_names(pattern: str | List[str] = None, filepath: str | Path = None) List[str]

Returns the list of objects names given a pattern. If a file is provided, search for names in the file instead of the current database.

Parameters:
pattern: str or list(str), optional

pattern to select a subset of objects. For example, ‘A*;*_’ will select all objects for which the name starts with ‘A’ or ends with ‘_’. Return all names contained in the database by default.

filepath: str or Path, optional

Path to the file to search for names. Search in the current database by default.

Returns:
list(str)

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading .../fun.cmt
317 objects loaded 
>>> comments.get_names("A*;*_")
['ACAF', 'ACAG', 'AOUC', 'AQC', 'BENEF_', 'GOSH_', 
'IDH_', 'PAFF_', 'PC_', 'PFI_', 'QAFF_', 'QAF_', 
'QAI_', 'QAT_', 'QBBPPOT_', 'QC_', 'QQMAB_', 'QS_', 
'Q_', 'TFPHP_', 'VAFF_', 'VAI_', 'VAT_', 'VC_', 'VS_', 
'WBF_', 'WBU_', 'WCF_', 'WCR1_', 'WCR2_', 'WIND_', 
'WNF_', 'YDH_', 'ZZ_']
>>> # or equivalently
>>> comments.get_names(["A*", "*_"])
['ACAF', 'ACAG', 'AOUC', 'AQC', 'BENEF_', 'GOSH_', 
'IDH_', 'PAFF_', 'PC_', 'PFI_', 'QAFF_', 'QAF_', 
'QAI_', 'QAT_', 'QBBPPOT_', 'QC_', 'QQMAB_', 'QS_', 
'Q_', 'TFPHP_', 'VAFF_', 'VAI_', 'VAT_', 'VC_', 'VS_', 
'WBF_', 'WBU_', 'WCF_', 'WCR1_', 'WCR2_', 'WIND_', 
'WNF_', 'YDH_', 'ZZ_']
>>> # get the list of all names
>>> comments.names
['ACAF', 'ACAG', 'AOUC', ..., 'ZKF', 'ZX', 'ZZ_']
>>> # search in file
>>> comments.clear()
>>> comments.get_names("A*;*_")
[]
>>> comments.get_names("A*;*_", f"{SAMPLE_DATA_DIR}/fun.cmt")
Loading ...\fun.cmt
317 objects loaded
['ACAF', 'ACAG', 'AOUC', 'AQC', 'BENEF_', 'GOSH_', 
'IDH_', 'PAFF_', 'PC_', 'PFI_', 'QAFF_', 'QAF_', 
'QAI_', 'QAT_', 'QBBPPOT_', 'QC_', 'QQMAB_', 'QS_', 
'Q_', 'TFPHP_', 'VAFF_', 'VAI_', 'VAT_', 'VC_', 'VS_', 
'WBF_', 'WBU_', 'WCF_', 'WCR1_', 'WCR2_', 'WIND_', 
'WNF_', 'YDH_', 'ZZ_']
>>> # empty pattern -> return no names
>>> comments.get_names("")
[]