@@ -330,6 +330,16 @@ def test_fit(self, params='stmc', n_iter=15, verbose=False, **kwargs):
330330 % (self .cvtype , params , trainll , np .diff (trainll )))
331331 self .assertTrue (np .all (np .diff (trainll ) > - 0.5 ))
332332
333+ def test_fit_works_on_sequences_of_different_length (self ):
334+ obs = [np .random .rand (3 , self .n_features ),
335+ np .random .rand (4 , self .n_features ),
336+ np .random .rand (5 , self .n_features )]
337+
338+ h = hmm .GaussianHMM (self .n_states , self .cvtype )
339+ # This shouldn't raise
340+ # ValueError: setting an array element with a sequence.
341+ h .fit (obs )
342+
333343 def test_fit_with_priors (self , params = 'stmc' , n_iter = 10 ,
334344 verbose = False ):
335345 startprob_prior = 10 * self .startprob + 2.0
@@ -612,6 +622,16 @@ def test_fit(self, params='stmwc', n_iter=5, verbose=True, **kwargs):
612622 np .diff (trainll ))
613623 self .assertTrue (np .all (np .diff (trainll ) > - 0.5 ))
614624
625+ def test_fit_works_on_sequences_of_different_length (self ):
626+ obs = [np .random .rand (3 , self .n_features ),
627+ np .random .rand (4 , self .n_features ),
628+ np .random .rand (5 , self .n_features )]
629+
630+ h = hmm .GMMHMM (self .n_states , cvtype = self .cvtype )
631+ # This shouldn't raise
632+ # ValueError: setting an array element with a sequence.
633+ h .fit (obs )
634+
615635
616636class TestGMMHMMWithSphericalCovars (TestGMMHMM ):
617637 cvtype = 'spherical'
0 commit comments