update version. tweak the test (install cython 3.0 for non-x64)
[MACS.git] / test / test_HMMR_HMM.py
blobce2ae967b93dda9e6ce6195fe68a11bb35c08fa3
1 import unittest
2 import pytest
3 from MACS3.Signal.HMMR_HMM import hmm_training, hmm_predict
4 import numpy as np
6 # ------------------------------------
7 # Main function
8 # ------------------------------------
9 ''' This unittest is to check the ouputs of the hmm_training() and hmm_predict() functions
10 '''
12 # @pytest.mark.skip(reason="need to refine later")
13 class Test_HMM_train(unittest.TestCase):
14 def setUp( self ):
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 )