def test_concatenate(): assert_array_equal(c(1, np.zeros(3)), np.array([1.0, 0.0, 0.0, 0.0])) assert_array_equal(c([1], np.zeros(3)), np.array([1.0, 0.0, 0.0, 0.0])) assert_array_equal(c(1), np.ones(1)) assert c() is None assert_array_equal(c([1]), np.ones(1))
def test_approx_rule2(): # for rule = 2 x, y = approx(table, tablep, stat, rule=2) assert_array_almost_equal(x, c(1.01)) assert_array_almost_equal(y, c(0.01))
def test_approx_rule1(): # for rule = 1 x, y = approx(table, tablep, stat, rule=1) assert_array_almost_equal(x, c(1.01)) assert_array_almost_equal(y, c(np.nan))
def test_regularize(): x, y = c(0.5, 0.5, 1.0, 1.5), c(1, 2, 3, 4) x, y = _regularize(x, y, 'mean') assert_array_almost_equal(x, np.array([0.5, 1.0, 1.5])) assert_array_almost_equal(y, np.array([1.5, 3.0, 4.0]))
# Test the approximation function from __future__ import absolute_import from pmdarima.arima.approx import approx, _regularize from pmdarima.utils.array import c from pmdarima.arima.stationarity import ADFTest from numpy.testing import assert_array_almost_equal import numpy as np import pytest table = c(0.216, 0.176, 0.146, 0.119) tablep = c(0.01, 0.025, 0.05, 0.10) stat = 1.01 def test_regularize(): x, y = c(0.5, 0.5, 1.0, 1.5), c(1, 2, 3, 4) x, y = _regularize(x, y, 'mean') assert_array_almost_equal(x, np.array([0.5, 1.0, 1.5])) assert_array_almost_equal(y, np.array([1.5, 3.0, 4.0])) def test_approx_rule1(): # for rule = 1 x, y = approx(table, tablep, stat, rule=1) assert_array_almost_equal(x, c(1.01)) assert_array_almost_equal(y, c(np.nan))
In this example, we demonstrate pyramid's array differencing, and how it's used in conjunction with the ``d`` term to lag a time series. .. raw:: html <br/> """ print(__doc__) # Author: Taylor Smith <*****@*****.**> from pmdarima.utils import array # Build an array and show first order differencing results x = array.c(10, 4, 2, 9, 34) lag_1 = array.diff(x, lag=1, differences=1) # The result will be the same as: x[1:] - x[:-1] print(lag_1) # [-6., -2., 7., 25.] # Note that lag and differences are not the same! If we crank diff up by one, # it performs the same differencing as above TWICE. Lag, therefore, controls # the number of steps backward the ts looks when it differences, and the # `differences` parameter controls how many times to repeat. print(array.diff(x, lag=1, differences=2)) # [4., 9., 18.] # Conversely, when we set lag to 2, the array looks two steps back for its # differencing operation (only one). print(array.diff(x, lag=2, differences=1)) # [-8., 5., 32.]