hxtorch.spiking.modules.types.ChainMap

class hxtorch.spiking.modules.types.ChainMap(*maps)

Bases: collections.abc.MutableMapping

A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view.

The underlying mappings are stored in a list. That list is public and can be accessed or updated using the maps attribute. There is no other state.

Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping.

__init__(*maps)

Initialize a ChainMap by setting maps to the given mappings. If no mappings are provided, a single empty dictionary is used.

Methods

__init__(*maps)

Initialize a ChainMap by setting maps to the given mappings.

clear()

Clear maps[0], leaving maps[1:] intact.

copy()

New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]

fromkeys(iterable, *args)

Create a ChainMap with a single dict created from the iterable.

get(k[,d])

new_child([m])

New ChainMap with a new map followed by all previous maps.

pop(key, *args)

Remove key from maps[0] and return its value.

popitem()

Remove and return an item pair from maps[0].

Attributes

parents

New ChainMap from maps[1:].

clear()

Clear maps[0], leaving maps[1:] intact.

copy()

New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]

classmethod fromkeys(iterable, *args)

Create a ChainMap with a single dict created from the iterable.

get(k[, d])D[k] if k in D, else d.  d defaults to None.
new_child(m=None, **kwargs)

New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict.

property parents

New ChainMap from maps[1:].

pop(key, *args)

Remove key from maps[0] and return its value. Raise KeyError if key not in maps[0].

popitem()

Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.