iode.Identities.__getitem__
- Identities.__getitem__(key: str | List[str]) Identity | Self[source]
Return the (subset of) identity(ies) 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 identity(ies) to get. The list of identities to get can be specified by a pattern or by a list of sub-patterns (e.g. “A*;*_”).
- Returns:
- Single identity or a subset of the database.
Examples
>>> from iode import SAMPLE_DATA_DIR >>> from iode import identities >>> identities.load(f"{SAMPLE_DATA_DIR}/fun.idt") Loading .../fun.idt 48 objects loaded
>>> # a) get one Identity >>> identities["AOUC"] Identity('((WCRH/QL)/(WCRH/QL)[1990Y1])*(VAFF/(VM+VAFF))[-1]+PM*(VM/(VM+VAFF))[-1]')
>>> # b) get a subset of the Identities database using a pattern >>> identities_subset = identities["X*"] >>> identities_subset.names ['XEX', 'XNATY', 'XPOIL', 'XPWMAB', 'XPWMS', 'XPWXAB', 'XPWXS', 'XQWXAB', 'XQWXS', 'XQWXSS', 'XRLBER', 'XTFP', 'XW']
>>> # c) get a subset of the Identities database using a list of names >>> identities_subset = identities[["XEX", "XPWMAB", "XPWMS", "XQWXS", "XTFP"]] >>> identities_subset.names ['XEX', 'XPWMAB', 'XPWMS', 'XQWXS', 'XTFP']