3 from MACS3
.Signal
.HMMR_HMM
import hmm_training
, hmm_predict
6 # ------------------------------------
8 # ------------------------------------
9 ''' This unittest is to check the ouputs of the hmm_training() and hmm_predict() functions
12 # @pytest.mark.skip(reason="need to refine later")
13 class Test_HMM_train(unittest
.TestCase
):
15 self
.train_data
= np
.loadtxt("test/large_training_data.txt", delimiter
="\t", dtype
="float", usecols
=(2,3,4,5)).tolist()
16 self
.training_data_lengths
= np
.loadtxt('test/large_training_lengths.txt', dtype
="int").tolist()
17 self
.expected_converged
= True
18 self
.not_expected_covars
= None
19 self
.not_expected_means
= None
20 self
.not_expected_transmat
= None
22 def test_predict( self
):
23 model
= hmm_training(training_data
= self
.train_data
, training_data_lengths
= self
.training_data_lengths
, n_states
= 3, random_seed
= 12345)
25 self
.assertEqual( model
.monitor_
.converged
, self
.expected_converged
)
26 self
.assertNotEqual( model
.covars_
.tolist(), self
.not_expected_covars
)
27 self
.assertNotEqual( model
.means_
.tolist(), self
.not_expected_means
)
28 self
.assertNotEqual( model
.transmat_
.tolist(), self
.not_expected_transmat
)