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

__init__

clear

D.clear() -> None.

copy

filter

Filter self based on kwargs

filter_nones

get

D.get(k[,d]) -> D[k] if k in D, else d.

items

D.items() -> a set-like object providing a view on D's items

keys

D.keys() -> a set-like object providing a view on D's keys

pop

D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

popitem

D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.

setdefault

D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D

update

D.update([E, ]**F) -> None.

values

D.values() -> an object providing a view on D's values