colour.continuous.MultiSignals

class colour.continuous.MultiSignals(data=None, domain=None, labels=None, **kwargs)[source]

Defines the base class for multi-continuous signals, a container for multiple colour.continuous.Signal sub-class instances.

Parameters:
Other Parameters:
 
  • name (unicode, optional) – multi-continuous signals name.
  • dtype (type, optional) – {np.float16, np.float32, np.float64, np.float128}, Floating point data type.
  • interpolator (object, optional) – Interpolator class type to use as interpolating function for the colour.continuous.Signal sub-class instances.
  • interpolator_args (dict_like, optional) – Arguments to use when instantiating the interpolating function of the colour.continuous.Signal sub-class instances.
  • extrapolator (object, optional) – Extrapolator class type to use as extrapolating function for the colour.continuous.Signal sub-class instances.
  • extrapolator_args (dict_like, optional) – Arguments to use when instantiating the extrapolating function of the colour.continuous.Signal sub-class instances.
  • signal_type (type, optional) – The colour.continuous.Signal sub-class type used for instances.
dtype
domain
range
interpolator
interpolator_args
extrapolator
extrapolator_args
function
signals
labels
signal_type
__str__()[source]
__repr__()[source]
__hash__()[source]
__getitem__()[source]
__setitem__()[source]
__contains__()[source]
__eq__()[source]
__ne__()[source]
arithmetical_operation()[source]
multi_signals_unpack_data()[source]
fill_nan()[source]
to_dataframe()[source]

Examples

Instantiation with implicit domain and a single signal:

>>> range_ = np.linspace(10, 100, 10)
>>> print(MultiSignals(range_))
[[   0.   10.]
 [   1.   20.]
 [   2.   30.]
 [   3.   40.]
 [   4.   50.]
 [   5.   60.]
 [   6.   70.]
 [   7.   80.]
 [   8.   90.]
 [   9.  100.]]

Instantiation with explicit domain and a single signal:

>>> domain = np.arange(100, 1100, 100)
>>> print(MultiSignals(range_, domain))
[[  100.    10.]
 [  200.    20.]
 [  300.    30.]
 [  400.    40.]
 [  500.    50.]
 [  600.    60.]
 [  700.    70.]
 [  800.    80.]
 [  900.    90.]
 [ 1000.   100.]]

Instantiation with multiple signals:

>>> range_ = tstack([np.linspace(10, 100, 10)] * 3)
>>> range_ += np.array([0, 10, 20])
>>> print(MultiSignals(range_, domain))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Instantiation with a dict:

>>> print(MultiSignals(dict(zip(domain, range_))))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Instantiation using a Signal sub-class:

>>> class NotSignal(Signal):
...     pass
>>> multi_signals = MultiSignals(range_, domain, signal_type=NotSignal)
>>> print(multi_signals)
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]
 >>> type(multi_signals.signals[0])  # doctest: +SKIP
 <class 'multi_signals.NotSignal'>

Instantiation with a Pandas Series:

>>> if is_pandas_installed():
...     from pandas import Series
...     print(MultiSignals(  # doctest: +SKIP
...         Series(dict(zip(domain, np.linspace(10, 100, 10))))))
[[  100.    10.]
 [  200.    20.]
 [  300.    30.]
 [  400.    40.]
 [  500.    50.]
 [  600.    60.]
 [  700.    70.]
 [  800.    80.]
 [  900.    90.]
 [ 1000.   100.]]

Instantiation with a Pandas Dataframe:

>>> if is_pandas_installed():
...     from pandas import DataFrame
...     data = dict(zip(['a', 'b', 'c'], tsplit(range_)))
...     print(MultiSignals(  # doctest: +SKIP
...         DataFrame(data, domain)))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Retrieving domain y variable for arbitrary range x variable:

>>> x = 150
>>> range_ = tstack([np.sin(np.linspace(0, 1, 10))] * 3)
>>> range_ += np.array([0.0, 0.25, 0.5])
>>> MultiSignals(range_, domain)[x]  # doctest: +ELLIPSIS
array([ 0.0359701...,  0.2845447...,  0.5331193...])
>>> x = np.linspace(100, 1000, 3)
>>> MultiSignals(range_, domain)[x]  # doctest: +ELLIPSIS
array([[  4.4085384...e-20,   2.5000000...e-01,   5.0000000...e-01],
       [  4.7669395...e-01,   7.2526859...e-01,   9.7384323...e-01],
       [  8.4147098...e-01,   1.0914709...e+00,   1.3414709...e+00]])

Using an alternative interpolating function:

>>> x = 150
>>> from colour.algebra import CubicSplineInterpolator
>>> MultiSignals(
...     range_,
...     domain,
...     interpolator=CubicSplineInterpolator)[x]  # doctest: +ELLIPSIS
array([ 0.0555274...,  0.3055274...,  0.5555274...])
>>> x = np.linspace(100, 1000, 3)
>>> MultiSignals(
...     range_,
...     domain,
...     interpolator=CubicSplineInterpolator)[x]  # doctest: +ELLIPSIS
array([[ 0.       ...,  0.25     ...,  0.5      ...],
       [ 0.4794253...,  0.7294253...,  0.9794253...],
       [ 0.8414709...,  1.0914709...,  1.3414709...]])
__init__(data=None, domain=None, labels=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([data, domain, labels]) Initialize self.
arithmetical_operation(a, operation[, in_place]) Performs given arithmetical operation with \(a\) operand, the operation can be either performed on a copy or in-place.
copy() Returns a copy of the sub-class instance.
domain_distance(a) Returns the euclidean distance between given array and independent domain \(x\) closest element.
fill_nan([method, default]) Fill NaNs in independent domain \(x\) variable and corresponding range \(y\) variable using given method.
is_uniform() Returns if independent domain \(x\) variable is uniform.
multi_signals_unpack_data([data, domain, …]) Unpack given data for multi-continuous signals instantiation.
to_dataframe() Converts the continuous signal to a Pandas DataFrame class instance.

Attributes

domain Getter and setter property for the colour.continuous.Signal sub-class instances independent domain \(x\) variable.
dtype Getter and setter property for the continuous signal dtype.
extrapolator Getter and setter property for the colour.continuous.Signal sub-class instances extrapolator type.
extrapolator_args Getter and setter property for the colour.continuous.Signal sub-class instances extrapolator instantiation time arguments.
function Getter and setter property for the colour.continuous.Signal sub-class instances callable.
interpolator Getter and setter property for the colour.continuous.Signal sub-class instances interpolator type.
interpolator_args Getter and setter property for the colour.continuous.Signal sub-class instances interpolator instantiation time arguments.
labels Getter and setter property for the colour.continuous.Signal sub-class instances name.
name Getter and setter property for the abstract continuous function name.
range Getter and setter property for the colour.continuous.Signal sub-class instances corresponding range \(y\) variable.
signal_type Getter and setter property for the colour.continuous.Signal sub-class instances type.
signals Getter and setter property for the colour.continuous.Signal sub-class instances.