colour_hdri.utilities.common Module — Colour - HDRI 0.1.0 documentation

# 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)

  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`()

  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']
      defaultdict(<function vivification at 0x...>, {u'attribute': 1})
      >>> vivified['my']['attribute']
      1

`colour_hdri.utilities.common.` `vivified_to_dict`(vivified)

  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}}

`colour_hdri.utilities.common.` `path_exists`(path)

  Returns if given path exists.

  Parameters: | path (unicode) – Path to check the existence.
  Returns: |
  Return type: | bool

  Examples

      >>> path_exists(__file__)
      True
      >>> path_exists('')
      False

`colour_hdri.utilities.common.` `filter_files`(directory, extensions)

  Filters given directory for files matching given extensions.

  Parameters: | directory (unicode) – Directory to filter. extensions (tuple or list) – Extensions to filter on.
  Returns: | Filtered files.
  Return type: | list