1111from scipy import sparse
1212import itertools
1313from numpy .testing import (
14- assert_allclose , assert_array_equal , assert_array_less , assert_raises
14+ assert_allclose , assert_array_equal , assert_array_less , assert_raises ,
15+ assert_
1516)
16- from nose .tools import eq_ , ok_ , raises
1717
1818from quantecon .markov import (
1919 MarkovChain , mc_compute_stationary , mc_sample_path
@@ -27,7 +27,7 @@ def list_of_array_equal(s, t):
2727 s, t: lists of numpy.ndarrays
2828
2929 """
30- eq_ (len (s ), len (t ))
30+ assert_ (len (s ) == len (t ))
3131 all (assert_array_equal (x , y ) for x , y in zip (s , t ))
3232
3333
@@ -191,7 +191,7 @@ class Test_markovchain_stationary_distributions_KMRMarkovMatrix2():
191191 p = 1 / 3
192192 TOL = 1e-2
193193
194- def setUp (self ):
194+ def setup (self ):
195195 """ Setup a KMRMarkovMatrix and Compute Stationary Values """
196196 self .P = KMR_Markov_matrix_sequential (self .N , self .p , self .epsilon )
197197 self .mc = MarkovChain (self .P )
@@ -315,7 +315,7 @@ def test_simulate_ergodicity():
315315
316316 x = mc .simulate (ts_length , init = init , num_reps = num_reps , random_state = seed )
317317 frequency_1 = x [:, - 1 ].mean ()
318- ok_ (np .abs (frequency_1 - stationary_dist [1 ]) < tol )
318+ assert_ (np .abs (frequency_1 - stationary_dist [1 ]) < tol )
319319
320320
321321def test_simulate_for_matrices_with_C_F_orders ():
@@ -405,11 +405,11 @@ def test_mc_sample_path_lln():
405405
406406 frequency_1 = mc_sample_path (P , init = init , sample_size = sample_size ,
407407 random_state = seed ).mean ()
408- ok_ (np .abs (frequency_1 - stationary_dist [1 ]) < tol )
408+ assert_ (np .abs (frequency_1 - stationary_dist [1 ]) < tol )
409409
410410
411411class TestMCStateValues :
412- def setUp (self ):
412+ def setup (self ):
413413 state_values = [[0 , 1 ], [2 , 3 ], [4 , 5 ]] # Pass python list
414414 self .state_values = np .array (state_values )
415415
@@ -519,29 +519,28 @@ def test_get_index():
519519 P = [[0.4 , 0.6 ], [0.2 , 0.8 ]]
520520 mc = MarkovChain (P )
521521
522- eq_ (mc .get_index (0 ), 0 )
523- eq_ (mc .get_index (1 ), 1 )
522+ assert_ (mc .get_index (0 ) == 0 )
523+ assert_ (mc .get_index (1 ) == 1 )
524524 assert_raises (ValueError , mc .get_index , 2 )
525525 assert_array_equal (mc .get_index ([1 , 0 ]), [1 , 0 ])
526526 assert_raises (ValueError , mc .get_index , [[1 ]])
527527
528528 mc .state_values = [1 , 2 ]
529- eq_ (mc .get_index (1 ), 0 )
530- eq_ (mc .get_index (2 ), 1 )
529+ assert_ (mc .get_index (1 ) == 0 )
530+ assert_ (mc .get_index (2 ) == 1 )
531531 assert_raises (ValueError , mc .get_index , 0 )
532532 assert_array_equal (mc .get_index ([2 , 1 ]), [1 , 0 ])
533533 assert_raises (ValueError , mc .get_index , [[1 ]])
534534
535535 mc .state_values = [[1 , 2 ], [3 , 4 ]]
536- eq_ (mc .get_index ([1 , 2 ]), 0 )
536+ assert_ (mc .get_index ([1 , 2 ]) == 0 )
537537 assert_raises (ValueError , mc .get_index , 1 )
538538 assert_array_equal (mc .get_index ([[3 , 4 ], [1 , 2 ]]), [1 , 0 ])
539539
540540
541- @raises (ValueError )
542541def test_raises_value_error_non_2dim ():
543542 """Test with non 2dim input"""
544- MarkovChain ( np .array ([0.4 , 0.6 ]))
543+ assert_raises ( ValueError , MarkovChain , np .array ([0.4 , 0.6 ]))
545544
546545
547546def test_raises_value_error_non_sym ():
@@ -581,13 +580,3 @@ def test_raises_non_homogeneous_state_values():
581580 P = [[0.4 , 0.6 ], [0.2 , 0.8 ]]
582581 state_values = [(0 , 1 ), 2 ]
583582 assert_raises (ValueError , MarkovChain , P , state_values = state_values )
584-
585-
586- if __name__ == '__main__' :
587- import sys
588- import nose
589-
590- argv = sys .argv [:]
591- argv .append ('--verbose' )
592- argv .append ('--nocapture' )
593- nose .main (argv = argv , defaultTest = __file__ )
0 commit comments