iode.Database.__delitem__

Note

Below, Database represents either:

  • Comments

  • Equations

  • Identities

  • Lists

  • Scalars

  • Tables

  • Variables

Database.__delitem__()

Remove the (subset of) IODE object(s) referenced by key from the current database.

Parameters:
key: str or list(str)

(list of) name(s) of the IODE object(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 comments
>>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt")
>>> comments.get_names("A*")
['ACAF', 'ACAG', 'AOUC', 'AQC']
>>> # a) delete one comment
>>> del comments["ACAF"]
>>> comments.get_names("A*")
['ACAG', 'AOUC', 'AQC']
>>> # b) delete several comments at once using a pattern
>>> del comments["A*"]
>>> comments.get_names("A*")
[]
>>> # c) delete several comments at once using a list of names
>>> comments.get_names("B*")
['BENEF', 'BENEF_', 'BQY', 'BVY']
>>> del comments[["BENEF", "BQY"]]
>>> comments.get_names("B*")
['BENEF_', 'BVY']
>>> # delete one comment from a subset of the global database
>>> comments_subset = comments["D*"]
>>> comments_subset.names
['DPU', 'DPUF', 'DPUG', 'DPUGO', 'DPUH', 'DPUU', 'DTF', 'DTFX', 'DTH', 'DTH1', 'DTH1C', 'DTHX']
>>> del comments_subset["DPUGO"]
>>> comments_subset.names
['DPU', 'DPUF', 'DPUG', 'DPUH', 'DPUU', 'DTF', 'DTFX', 'DTH', 'DTH1', 'DTH1C', 'DTHX']
>>> # comment also deleted in the globale database
>>> "DPUGO" in comments
False
>>> comments.get_names("D*")
['DPU', 'DPUF', 'DPUG', 'DPUH', 'DPUU', 'DTF', 'DTFX', 'DTH', 'DTH1', 'DTH1C', 'DTHX']