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

copy

filter

Filter self based on kwargs

filter_nones

get

items

keys

pop

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem

as a 2-tuple; but raise KeyError if D is empty.

setdefault

update

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values