braincore.util.DictManager

braincore.util.DictManager#

class braincore.util.DictManager[source]#

DictManager, for collecting all pytree used in the program.

DictManager supports all features of python dict.

__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

add_unique_elem(key, var)

Add a new element.

assign(*args)

Assign the value for each element according to the given data.

clear()

copy()

difference_by_keys(keys)

Get the difference of the stack by the keys.

difference_by_values(values[, by])

Get the difference of the stack by the values.

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

intersection_by_keys(keys)

Get the intersection of the stack by the keys.

intersection_by_values(values[, by])

Get the intersection of the stack by the values.

items()

keys()

not_subset(sep)

Get a new stack with the subset of keys.

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

pop_by_keys(keys)

Pop the elements by the keys.

pop_by_values(values[, by])

Pop the elements by the values.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

split(first, *others)

Split the stack into subsets of stack by the given types.

subset(sep)

Get a new stack with the subset of keys.

to_dict()

Convert the stack to a dict.

tree_flatten()

tree_unflatten(keys, values)

union_by_value_ids(other)

Union the stack by the value ids.

unique()

Get a new type of collections with unique values.

update([E, ]**F)

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

values()