colour_hdri.utilities.common Module¶
Common Utilities¶
Defines common utilities objects that don’t fall in any specific category.
-
colour_hdri.utilities.common.
linear_conversion
(a, old_range, new_range)[source]¶ Performs a simple linear conversion of given array between the old and new ranges.
Parameters: - a (array_like) – Array to perform the linear conversion onto.
- old_range (array_like) – Old range.
- new_range (array_like) – New range.
Returns: Return type: ndarray
Examples
>>> a = np.linspace(0, 1, 10) >>> linear_conversion(a, np.array([0, 1]), np.array([1, 10])) array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
-
colour_hdri.utilities.common.
vivification
()[source]¶ Implements supports for vivification of the underlying dict like data-structure, magical!
Returns: Return type: defaultdict Examples
>>> vivified = vivification() >>> vivified['my']['attribute'] = 1 >>> vivified['my'] # doctest: +ELLIPSIS defaultdict(<function vivification at 0x...>, {u'attribute': 1}) >>> vivified['my']['attribute'] 1
-
colour_hdri.utilities.common.
vivified_to_dict
(vivified)[source]¶ Converts given vivified data-structure to dictionary.
Parameters: vivified (defaultdict) – Vivified data-structure. Returns: Return type: dict Examples
>>> vivified = vivification() >>> vivified['my']['attribute'] = 1 >>> vivified_to_dict(vivified) {u'my': {u'attribute': 1}}