Dicts

class DictCell(from_dict=None)[source]

This is a wrapper for a dictionary of cells. Can be compared with another DictCell.

Unlike the other primitive structures, a DictCell cannot be coerced into something else.

Parameters:from_dict (dict) – Optional parameter specifying initial dictionary, where the value of each (key,value) pair must be a Cell. Defaults to an empty dictionary.
contains(key_or_keypath)[source]

Allows the ‘in’ operator to work for checking if a particular key (or keypath) is inside the dictionary.

Parameters:key_or_keypath – A single key or a path of keys in the form of a list
Returns:bool
get_value_from_path(keypath)[source]

Returns the value at the end of keypath (or None) keypath is a list of keys, e.g., [“key”, “subkey”, “subsubkey”]

Parameters:keypath (list) – A list of keys representing a path through nested dictionaries
Returns:value associated with final key in keypath
is_entailed_by(other)[source]

Whether all of self’s keys (and values) are in (and within) other’s

Parameters:other (DictCell) – A DictCell to check
Returns:bool
entails(other)[source]

Whether the target of the other belief state is strictly more general than the caller belief state

Parameters:other (DictCell) – A DictCell to check
Returns:bool
is_contradictory(other)[source]

Returns True if the two DictCells are unmergeable, i.e. if the two DictCells share a key, but the Cells associated with those keys are unMergeable.

Parameters:other (DictCell) – DictCell to check
Returns:bool
Raises:Exception
is_equal(other)[source]

Two DictCells are equal when they share ALL Keys, and all of their is_equal() methods return True. This ensures substructure equality.

Parameters:other (DictCell) – DictCell to compare
Returns:bool
merge(other)[source]

Merges two complex structures (by recursively merging their parts). Missing-parts do not trigger contradictions.

Parameters:other (DictCell) – DictCell to merge
Returns:DictCell
Raises:Exception, Contradiction
to_dict()[source]

This method converts the DictCell into a python dict. This is useful for JSON serialization.

Returns:dict
to_latex()[source]

Returns a LaTeX representation of an attribute-value matrix

empty()[source]

Returns True iff the dictionary doesn’t have any keys

keys()[source]

Returns a list of the top-level keys in the DictCell

Returns:list
values()[source]

Returns a list of the top-level values in the DictCell

Returns:list
items()[source]

Returns both keys and values in dictionary

Returns:list of tuples

Previous topic

Colors

Next topic

Lists

This Page