Dictionary table¶
-
class
arepy.data.
dictTab
(keys, items=None)¶ Dictionary table
- Variables
or dict[dict] items (list[dict]) – List of items
size (int) – Size of the list
keys (list[str]) – Column names (keys)
- Parameters
keys (list[str]) – Column names (keys)
items – List of table rows (values)
- Key items
list[tuple] or dict[dict]
- Returns
Object of self
This purely cosmetic function converts tabulated parameters into a list of dictionaries. It makes the code a bit neater and more readable
Examples:
Return a list:
>>> props = apy.data.dictTab(['key','label','scale'],[ >>> ('X_H2', '$X_\mathrm{H_2}$','lin'), >>> ('Mass', 'M ($M_\odot$)', 'log'), >>> ]) >>> props.items [{'key':'X_H2', 'label':'$X_\mathrm{H_2}$', 'scale':'lin'} {'key':'Mass', 'label':'M ($M_\odot$)', 'scale':'log'}]
Return a dictionary:
>>> props = apy.data.dictTab(['key','label','scale'],{ >>> "item1": ('X_H2', '$X_\mathrm{H_2}$','lin'), >>> "item2": ('Mass', 'M ($M_\odot$)', 'log'), >>> }) >>> props.items {"item1": {'key':'X_H2', 'label':'$X_\mathrm{H_2}$', 'scale':'lin'} "item2": {'key':'Mass', 'label':'M ($M_\odot$)', 'scale':'log'}}
-
addItems
(items)¶ Add rows to the table
- Parameters
items (touple) – Table row (dictionary values)
-
getColumn
(col)¶ Get column from a table
- Parameters
col (str) – A dictionary key to select
- Return list
List of values selected by a key
-
correlate
()¶ Return a correlation of the items
- Returns
Data correlation list
- Return type
arepy.data.correlate