topologicpy.Dictionary module
- class topologicpy.Dictionary.Dictionary
Bases:
objectMethods
AdjacencyDictionary(topology[, ...])Returns the adjacency dictionary of the input topology or graph.
BooleanDictionariesByKey(dictionariesA, ...)Booleans the keys/values of the dictionaries in the second list on the dictionaries in the first list based on a shared dictionary key/value and the boolean operation.
ByKeyValue(key, value[, silent])Creates a Dictionary from the input key and the input value.
ByKeysValues(keys, values[, silent])Creates a Dictionary from the input list of keys and the input list of values.
ByMergedDictionaries(*dictionaries[, silent])Creates a dictionary by merging the input dictionaries.
ByObjectProperties(bObject, keys, importAll)Creates a dictionary from selected Blender object properties.
ByPythonDictionary(pythonDictionary[, silent])Creates a Core/topologic dictionary equivalent to the input Python dictionary or dictionary-bearing TGraph object/record.
Copy(dictionary[, silent])Creates a copy of the input dictionary-like object as a Core/topologic dictionary.
Difference(dictionaryA, dictionaryB[, silent])Returns the difference of dictionaryA and dictionaryB (A B), based on keys.
Filter(elements, dictionaries[, searchType, ...])Filters the input list of dictionaries based on the input parameters.
Impose(dictionaryA, dictionaryB[, silent])Imposes dictionaryB onto dictionaryA.
Imprint(dictionaryA, dictionaryB[, silent])Imprints dictionaryB onto dictionaryA by replacing values only for keys already present in dictionaryA.
Intersection(dictionaryA, dictionaryB[, silent])Returns the intersection of dictionaryA and dictionaryB, based on keys.
Keys(dictionary[, silent])Returns the keys of the input dictionary.
KeysAtValue(dictionary, value[, silent])Returns all keys in the input dictionary whose value matches the input value.
ListAttributeValues(listAttribute)Returns the list of values embedded in the input listAttribute.
Merge(dictionaryA, dictionaryB[, silent])Returns the merge (union) of dictionaryA and dictionaryB.
OneHotEncode(d, keys, categoriesByKey[, silent])One-hot encodes multiple categorical dictionary values in one pass.
PythonDictionary(dictionary[, silent])Returns the input dictionary-like object as a Python dictionary.
RemoveKey(dictionary, key[, silent, ...])Removes the key and its associated value from the input dictionary.
SetValueAtKey(dictionary, key, value[, silent])Creates or updates a key/value pair in the input dictionary.
SetValuesAtKeys(dictionary, keys, values[, ...])Creates or updates multiple key/value pairs in the input dictionary.
SymDif(dictionaryA, dictionaryB[, silent])Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.
SymmetricDifference(dictionaryA, dictionaryB)Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.
Union(dictionaryA, dictionaryB[, silent])Returns the union (merge) of dictionaryA and dictionaryB.
ValueAtKey(dictionary, key[, defaultValue, ...])Returns the value at the input key in the input dictionary.
Values(dictionary[, silent])Returns the list of values in the input dictionary-like object.
ValuesAtKeys(dictionary, keys[, ...])Returns the list of values of the input list of keys in the input dictionary.
XOR(dictionaryA, dictionaryB[, silent])Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.
- static AdjacencyDictionary(topology, subTopologyType: str = None, labelKey: str = None, weightKey: str = None, includeWeights: bool = False, mantissa: int = 6, silent: bool = False)
Returns the adjacency dictionary of the input topology or graph.
- Parameters
- topologytopologic_core.Topology, topologic_core.Graph, or topologicpy.TGraph
The input topology or graph.
- subTopologyTypestr , optional
The type of subTopology on which to base the adjacency dictionary.
- labelKeystr , optional
The returned subTopologies are labelled according to the dictionary values stored under this key. If the labelKey does not exist, it will be created and the subTopologies are labelled numerically and stored in the subTopologies’ dictionary under this key. Default is None.
- weightKeystr , optional
If set, the sharedTopologies’ dictionaries will be searched for this key to set their weight. If the key is set to “Area” or “Length” (case insensitive), the area of shared faces or the length of the shared edges will be used as its weight. If set to None, a weight of 1 will be used. Default is None.
- includeWeightsbool , optional
If set to True, edge weights are included. Otherwise, they are not. Default is False.
- mantissaint , optional
The number of decimal places to round the result to. Default is 6.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- dict
The adjacency dictionary.
- static BooleanDictionariesByKey(dictionariesA, dictionariesB, key: str, operation: str = 'union', exclusive: bool = True, silent: bool = False)
Booleans the keys/values of the dictionaries in the second list on the dictionaries in the first list based on a shared dictionary key/value and the boolean operation.
- static ByKeyValue(key, value, silent: bool = False)
Creates a Dictionary from the input key and the input value.
- Parameters
- keystr
The string representing the key of the value in the dictionary.
- valueint, float, str, or list
A value corresponding to the input key. A value can be an integer, a float, a string, or a list.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Dictionary
The created dictionary.
- static ByKeysValues(keys, values, silent: bool = False)
Creates a Dictionary from the input list of keys and the input list of values.
- Parameters
- keyslist
A list of strings representing the keys of the dictionary.
- valueslist
A list of values corresponding to the list of keys. Values can be integers, floats, strings, or lists
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Dictionary
The created dictionary.
- static ByMergedDictionaries(*dictionaries, silent: bool = False)
Creates a dictionary by merging the input dictionaries.
The inputs can be Python dictionaries, Core/topologic dictionaries, backend dictionary objects, topologicpy.TGraph instances, TGraph vertex records, or TGraph edge records. None values are preserved when the key exists; missing keys and stored None values are not conflated.
- Parameters
- dictionarieslist or comma separated dictionaries
The input dictionaries to be merged.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Dictionary
The created dictionary.
- static ByObjectProperties(bObject, keys, importAll)
Creates a dictionary from selected Blender object properties.
- Parameters
- bObjectobject
The input object whose properties are to be imported.
- keyslist or str
The property keys to import when importAll is False.
- importAllbool
If True, standard object properties and scalar custom properties are imported.
- Returns
- topologic_core.Dictionary
The created dictionary.
- static ByPythonDictionary(pythonDictionary, silent: bool = False)
Creates a Core/topologic dictionary equivalent to the input Python dictionary or dictionary-bearing TGraph object/record.
- Parameters
- pythonDictionarydict, topologicpy.TGraph, TGraph vertex record, or TGraph edge record
The input dictionary-like object.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- topologic_core.Dictionary
The dictionary equivalent to the input dictionary.
- static Copy(dictionary, silent: bool = False)
Creates a copy of the input dictionary-like object as a Core/topologic dictionary.
- static Difference(dictionaryA, dictionaryB, silent: bool = False)
Returns the difference of dictionaryA and dictionaryB (A B), based on keys.
- static Filter(elements, dictionaries, searchType='any', key=None, value=None)
Filters the input list of dictionaries based on the input parameters.
If searchType is “any”, all dictionary values are searched for the input value. Otherwise, the supplied key is used.
- static Impose(dictionaryA, dictionaryB, silent: bool = False)
Imposes dictionaryB onto dictionaryA.
- static Imprint(dictionaryA, dictionaryB, silent: bool = False)
Imprints dictionaryB onto dictionaryA by replacing values only for keys already present in dictionaryA.
- static Intersection(dictionaryA, dictionaryB, silent: bool = False)
Returns the intersection of dictionaryA and dictionaryB, based on keys.
- static Keys(dictionary, silent: bool = False)
Returns the keys of the input dictionary.
- static KeysAtValue(dictionary, value, silent=False)
Returns all keys in the input dictionary whose value matches the input value.
- static ListAttributeValues(listAttribute)
Returns the list of values embedded in the input listAttribute.
- static Merge(dictionaryA, dictionaryB, silent: bool = False)
Returns the merge (union) of dictionaryA and dictionaryB.
- static OneHotEncode(d, keys, categoriesByKey, silent=False)
One-hot encodes multiple categorical dictionary values in one pass.
For Python dictionaries, TGraphs, and TGraph vertex/edge records, the original container is updated and returned. For Core/topologic dictionaries, a new Core/topologic dictionary is returned. See https://en.wikipedia.org/wiki/One-hot.
- static PythonDictionary(dictionary, silent: bool = False)
Returns the input dictionary-like object as a Python dictionary.
- Parameters
- dictionarydict, topologic_core.Dictionary, backend dictionary, topologicpy.TGraph, TGraph vertex record, or TGraph edge record
The input dictionary or dictionary-bearing object.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- dict or None
A Python dictionary copy.
- static RemoveKey(dictionary, key, silent: bool = False, caseSensitive: bool = False)
Removes the key and its associated value from the input dictionary.
For Python dictionaries, TGraphs, and TGraph vertex/edge records, the original container is updated and returned. For Core/topologic dictionaries, a new Core/topologic dictionary is returned.
- static SetValueAtKey(dictionary, key, value, silent: bool = False)
Creates or updates a key/value pair in the input dictionary.
For Python dictionaries, TGraphs, and TGraph vertex/edge records, the original container is updated and returned. For Core/topologic dictionaries, a new Core/topologic dictionary is returned.
- static SetValuesAtKeys(dictionary, keys, values, silent: bool = False)
Creates or updates multiple key/value pairs in the input dictionary.
For Python dictionaries, TGraphs, and TGraph vertex/edge records, the original container is updated and returned. For Core/topologic dictionaries, a new Core/topologic dictionary is returned.
- static SymDif(dictionaryA, dictionaryB, silent: bool = False)
Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.
- static SymmetricDifference(dictionaryA, dictionaryB, silent: bool = False)
Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.
- static Union(dictionaryA, dictionaryB, silent: bool = False)
Returns the union (merge) of dictionaryA and dictionaryB.
- static ValueAtKey(dictionary, key, defaultValue=None, silent=False)
Returns the value at the input key in the input dictionary.
If the dictionary or key is invalid, or the key does not exist, defaultValue is returned. If a key exists with value None, None is returned, matching Python dict.get semantics.
- static Values(dictionary, silent: bool = False)
Returns the list of values in the input dictionary-like object.
- static ValuesAtKeys(dictionary, keys, defaultValue=None, silent: bool = False)
Returns the list of values of the input list of keys in the input dictionary.
- static XOR(dictionaryA, dictionaryB, silent: bool = False)
Returns the symmetric difference (XOR) of dictionaryA and dictionaryB, based on keys.