check_attribute_color_range#

k3d.helpers.check_attribute_color_range(attribute: ndarray | Dict[str, ndarray], color_range: List[float] | Tuple[float, ...] = (), channels: bool = False) → List[float][source]#

Return color range versus provided attribute.

Parameters:
  • attribute (list or dict (for timeseries)) – Array of numbers.

  • color_range (tuple, optional) – Two numbers, by default ().

  • channels (bool, optional) – Whether a list means one attribute per channel, by default False. Only volume_slice takes several channels; everywhere else a list is one attribute written out by hand, and reading it as channels returns a range per slice that no trait accepts.

Returns:

Color range.

Return type:

tuple

Examples#

Color range#

import k3d
import numpy as np

attribute = np.linspace(0, 0.5, 100)

color_range = k3d.helpers.check_attribute_color_range(attribute, color_range=[0, 1])

"""
[0.0, 1.0]
"""

No color range#

import k3d
import numpy as np

attribute = np.linspace(0, 0.5, 100)

color_range = k3d.helpers.check_attribute_color_range(attribute)

"""
[0.0, 0.5]
"""