iode.Equations.__getitem__

Equations.__getitem__(key: str | List[str]) Equation | Self[source]

Return the (subset of) equation(s) referenced by key.

The key can represent a single object name (e.g. “ACAF”) or a list of object names (“ACAF;ACAG;AOUC”) or a pattern (e.g. “A*”) or a list of sub-patterns (e.g. “A*;*_”).

If the key represents a list of object names or of sub-patterns, each name or sub-pattern is separated by a separator character which is either a whitespace ` , or a comma `,, or a semi-colon ;, or a tabulation t, or a newline n.

A (sub-)`pattern` is a list of characters representing a group of object names. It includes some special characters which 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

Note that the key can contain references to IODE lists which are prefixed with the symbol $.

Parameters:
key: str or list(str)

(the list of) name(s) of the equation(s) to get. The list of equations to get can be specified by a pattern or by a list of sub-patterns (e.g. “A*;*_”).

Returns:
Single equation or a subset of the database.

Examples

>>> from iode import SAMPLE_DATA_DIR
>>> from iode import equations
>>> equations.load(f"{SAMPLE_DATA_DIR}/fun.eqs")
Loading .../fun.eqs
274 objects loaded 
>>> # a) get one equation
>>> equations["ACAF"]
Equation(endogenous = 'ACAF',
         lec = '(ACAF/VAF[-1]) :=acaf1+acaf2*GOSF[-1]+\nacaf4*(TIME=1995)',
         method = 'LSQ',
         from_period = '1980Y1',
         to_period = '1996Y1',
         block = 'ACAF',
         tests = {corr = 1,
                  dw = 2.32935,
                  fstat = 32.2732,
                  loglik = 83.8075,
                  meany = 0.00818467,
                  r2 = 0.821761,
                  r2adj = 0.796299,
                  ssres = 5.19945e-05,
                  stderr = 0.00192715,
                  stderrp = 23.5458,
                  stdev = 0.0042699},
         date = '12-06-1998')
>>> # b) get a subset of the Equations database using a pattern
>>> equations_subset = equations["A*"]
>>> equations_subset.names
['ACAF', 'ACAG', 'AOUC']
>>> # c) get a subset of the Equations database using a list of names
>>> equations_subset = equations[["ACAF", "AOUC", "BQY", "BVY"]]
>>> equations_subset.names
['ACAF', 'AOUC', 'BQY', 'BVY']