iode.Equations.__delitem__
- Equations.__delitem__(key)[source]
Remove the (subset of) equation(s) referenced by key from the Equations database.
- Parameters:
- key: str or list(str)
(list of) name(s) of the equation(s) to be removed. The list of names can be given as a string pattern (e.g. “A*;*_”).
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) delete one equation >>> equations.get_names("A*") ['ACAF', 'ACAG', 'AOUC'] >>> del equations["ACAF"] >>> equations.get_names("A*") ['ACAG', 'AOUC']
>>> # b) delete several equations at once using a pattern >>> del equations["A*"] >>> equations.get_names("A*") []
>>> # c) delete several equations at once using a list of names >>> equations.get_names("B*") ['BENEF', 'BQY', 'BRUGP', 'BVY'] >>> del equations[["BENEF", "BQY"]] >>> equations.get_names("B*") ['BRUGP', 'BVY']
>>> # delete one equation from a subset of the global database >>> equations_subset = equations["D*"] >>> equations_subset.names ['DEBT', 'DPU', 'DPUF', 'DPUG', 'DPUGO', 'DPUH', 'DPUU', 'DTF', 'DTH', 'DTH1', 'DTH1C'] >>> del equations_subset["DPUGO"] >>> equations_subset.names ['DEBT', 'DPU', 'DPUF', 'DPUG', 'DPUH', 'DPUU', 'DTF', 'DTH', 'DTH1', 'DTH1C'] >>> # NOTE: the equation has also been deleted from the global database >>> "DPUGO" in equations False >>> equations.get_names("D*") ['DEBT', 'DPU', 'DPUF', 'DPUG', 'DPUH', 'DPUU', 'DTF', 'DTH', 'DTH1', 'DTH1C']
>>> # store an equation in a Python variable >>> eq = equations["DEBT"] >>> eq Equation(endogenous = 'DEBT', lec = 'd DEBT := OCP-FLG', method = 'LSQ', comment = ' ', block = 'DEBT') >>> # then delete it from the database >>> del equations["DEBT"] >>> "DEBT" in equations False >>> # NOTE: the Python variable 'eq' still contains the equation object >>> eq Equation(endogenous = 'DEBT', lec = 'd DEBT := OCP-FLG', method = 'LSQ', comment = ' ', block = 'DEBT')