def test_interval(self): """ Tests :func:`colour.utilities.array.interval` definition. """ np.testing.assert_almost_equal(interval(range(0, 10, 2)), np.array([2])) np.testing.assert_almost_equal(interval([1, 2, 3, 4, 6, 6.5]), np.array([0.5, 1, 2]))
def test_interval(self): """ Tests :func:`colour.utilities.array.interval` definition. """ np.testing.assert_almost_equal( interval(range(0, 10, 2)), np.array([2])) np.testing.assert_almost_equal( interval([1, 2, 3, 4, 6, 6.5]), np.array([0.5, 1, 2]))
def x(self, value): """ Setter for **self.__x** private attribute. Parameters ---------- value : array_like Attribute value. """ if value is not None: value = np.atleast_1d(value).astype(np.float_) assert value.ndim == 1, ( '"x" independent variable must have exactly one dimension!') value_interval = interval(value)[0] xp1 = value[0] - value_interval * 2 xp2 = value[0] - value_interval xp3 = value[-1] + value_interval xp4 = value[-1] + value_interval * 2 self._xp = np.concatenate(((xp1, xp2), value, (xp3, xp4))) self.__x = value
def _evaluate(self, x): """ Performs the interpolator evaluation at given points. Parameters ---------- x : ndarray Points to evaluate the interpolant at. Returns ------- ndarray Interpolated points values. """ self._validate_dimensions() self._validate_interpolation_range(x) x_interval = interval(self._x)[0] x_f = np.floor(x / x_interval) windows = (x_f[:, np.newaxis] + np.arange(-self._window + 1, self._window + 1)) clip_l = min(self._x_p) / x_interval clip_h = max(self._x_p) / x_interval windows = np.clip(windows, clip_l, clip_h) - clip_l windows = np.around(windows).astype(np.int_) return np.sum( self._y_p[windows] * self._kernel(x[:, np.newaxis] / x_interval - windows - min(self._x_p) / x_interval, **self._kernel_args), axis=-1)
def x(self, value): """ Setter for the **self.x** property. """ if value is not None: value = np.atleast_1d(value).astype(self._dtype) assert value.ndim == 1, ( '"x" independent variable must have exactly one dimension!') value_interval = interval(value) if value_interval.size != 1: warning(('"x" independent variable is not uniform, ' 'unpredictable results may occur!')) self._x = value if self._window is not None: self._x_p = np.pad( self._x, (self._window, self._window), 'linear_ramp', end_values=( np.min(self._x) - self._window * value_interval[0], np.max(self._x) + self._window * value_interval[0]))
def x(self, value): """ Setter for the **self.x** property. """ if value is not None: value = np.atleast_1d(value).astype(self._dtype) assert value.ndim == 1, ( '"x" independent variable must have exactly one dimension!') value_interval = interval(value)[0] xp1 = value[0] - value_interval * 2 xp2 = value[0] - value_interval xp3 = value[-1] + value_interval xp4 = value[-1] + value_interval * 2 self._xp = np.concatenate(((xp1, xp2), value, (xp3, xp4))) self._x = value