skrf.util.HomoDict
- class skrf.util.HomoDict(dict_)[source]
A Homogeneous Mutable Mapping.
Provides a class for a dictionary-like object which contains homogeneous values. Attributes of the values can be accessed through the attributes of HomoDict. Searching is done like numpy arrays.
Initialized from a dictionary containing values of all the same type
>>> h = HomoDict({'a':Foo(...),'b': Foo(...), 'c':Foo(..)})
The individual values of h can be access in identical fashion to Dictionaries.
>>> h['key']
Assuming that Foo has property prop and function func …
Access elements’ properties:
>>> h.prop
Access elements’ functions:
>>> h.func()
Searching:
>>> h[h.prop == value] >>> h[h.prop < value]
Multiple search:
>>> h[set(h.prop==value1) & set( h.prop2==value2)]
Combos:
>>> h[h.prop==value].func()
Methods
D.clear() -> None. |
|
Filter self based on kwargs |
|
D.get(k[,d]) -> D[k] if k in D, else d. |
|
D.items() -> a set-like object providing a view on D's items |
|
D.keys() -> a set-like object providing a view on D's keys |
|
D.pop(k[,d]) -> v, remove specified key and return the corresponding value. |
|
D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. |
|
D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D |
|
D.update([E, ]**F) -> None. |
|
D.values() -> an object providing a view on D's values |