forked from QuantEcon/QuantEcon.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_arma.py
52 lines (35 loc) · 1.2 KB
/
test_arma.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Tests for arma.py file. Most of this testing can be considered
covered by the numpy tests since we rely on much of their code.
"""
import sys
import unittest
import numpy as np
from numpy.testing import assert_array_equal
from quantecon.arma import ARMA
class TestARMA(unittest.TestCase):
def setUp(self):
# Initial Values
phi = np.array([.95, -.4, -.4])
theta = np.zeros(3)
sigma = .15
self.lp = ARMA(phi, theta, sigma)
def tearDown(self):
del self.lp
def test_simulate(self):
lp = self.lp
sim = lp.simulation(ts_length=250)
self.assertTrue(sim.size==250)
def test_simulate_with_seed(self):
lp = self.lp
seed = 5
sim0 = lp.simulation(ts_length=10, random_state=seed)
sim1 = lp.simulation(ts_length=10, random_state=seed)
assert_array_equal(sim0, sim1)
def test_impulse_response(self):
lp = self.lp
imp_resp = lp.impulse_response(impulse_length=75)
self.assertTrue(imp_resp.size==75)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestARMA)
unittest.TextTestRunner(verbosity=2, stream=sys.stderr).run(suite)