topologicpy.Dictionary module
- class topologicpy.Dictionary.Dictionary
Bases:
objectMethods
AdjacencyDictionary(topology[, ...])Returns the adjacency dictionary of the input Shell.
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 list of input dictionaries.
ByMergedDictionaries_old(*dictionaries[, silent])Creates a dictionary by merging the list of input dictionaries.
ByObjectProperties(bObject, keys, importAll)- Parameters
ByPythonDictionary(pythonDictionary[, silent])Creates a dictionary equivalent to the input python dictionary.
Copy(dictionary[, silent])Creates a copy of the input 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.
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 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 a key/value pair 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.
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 Shell.
- Parameters
- topologytopologic_core.Topology
The input topology.
- 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 list of input dictionaries.
- Parameters
- dictionarieslist or comma separated dictionaries
The input list of 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 ByMergedDictionaries_old(*dictionaries, silent: bool = False)
Creates a dictionary by merging the list of input dictionaries.
- static ByObjectProperties(bObject, keys, importAll)
- Parameters
- bObjectTYPE
DESCRIPTION.
- keysTYPE
DESCRIPTION.
- importAllTYPE
DESCRIPTION.
- Returns
- TYPE
DESCRIPTION.
- Raises
- Exception
DESCRIPTION.
- static ByPythonDictionary(pythonDictionary, silent: bool = False)
Creates a dictionary equivalent to the input python dictionary.
- Parameters
- pythonDictionarydict
The input python dictionary.
- 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 python dictionary.
- static Copy(dictionary, silent: bool = False)
Creates a copy of the input 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.
- static Impose(dictionaryA, dictionaryB, silent: bool = False)
Imposes dictionaryB onto dictionaryA.
- static Imprint(dictionaryA, dictionaryB, silent: bool = False)
Imprints dictionaryB onto 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.
- Parameters
- dictionarydict or topologic_core.Dictionary
The input dictionary.
- valueany
The value to search for.
- silentbool , optional
If set to True, error messages are suppressed. Default is False.
- Returns
- list
The list of keys whose associated value matches the input value. Returns an empty list if no matches are found or if the input dictionary is invalid.
- 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. See https://en.wikipedia.org/wiki/One-hot
- static PythonDictionary(dictionary, silent: bool = False)
Returns the input dictionary as a python dictionary.
- static RemoveKey(dictionary, key, silent: bool = False)
Removes the key and its associated value from the input dictionary.
- static SetValueAtKey(dictionary, key, value, silent: bool = False)
Creates or updates a key/value pair in the input dictionary.
- static SetValuesAtKeys(dictionary, keys, values, silent: bool = False)
Creates a key/value pair in the input dictionary.
- 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 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.
- static Values(dictionary, silent: bool = False)
Returns the list of values in the input dictionary.
- static ValuesAtKeys(dictionary, keys, defaultValue=None, silent: bool = False)
Returns the list of values of the input list of keys in the input dictionary.
- Parameters
- dictionarytopologic_core.Dictionary, dict, or backend dictionary
The input dictionary.
- keyslist
The input list of keys.
- defaultValueany , optional
The default value to return if the key or value are not found. Default is None.
- silentbool , optional
If set to True, error and warning messages are suppressed. Default is False.
- Returns
- list
The list of values found at 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.