コード例 #1
0
    def test_with_vector_values(self):
        c = Components(use_trend=True, use_damped_trend=True,
                       use_arma_errors=True, use_box_cox=True, seasonal_periods=[7, 30], p=1, q=2)
        p = ModelParams(c, alpha=0.1, box_cox_lambda=1.4, beta=0.2, phi=0.3, gamma_params=[0.4, 0.5],
                        ar_coefs=[-0.3], ma_coefs=[-0.4, 0.6])
        v = p.to_vector()
        assert np.array_equal([0.1, 1.4, 0.2, 0.3, 0.4, 0.5, -0.3, -0.4, 0.6], v)

        p = ModelParams(c, alpha=0.9, box_cox_lambda=1.4)
        p = p.with_vector_values(v)
        assert p.alpha == 0.1
        assert p.box_cox_lambda == 1.4
        assert p.beta == 0.2
        assert p.phi == 0.3
        assert np.array_equal([0.4, 0.5], p.gamma_params)
        assert np.array_equal([-0.3], p.ar_coefs)
        assert np.array_equal([-0.4, 0.6], p.ma_coefs)
コード例 #2
0
 def test_to_vector(self, components, params, expected):
     c = Components(**components)
     p = ModelParams(c, **params)
     vector = p.to_vector()
     assert np.array_equal(expected, vector)