Fix bug identified in #1817, comment 17340049
diff --git a/sklearn/hmm.py b/sklearn/hmm.py
index 2b3c86d326d4c..3e60a85fc0645 100644
--- a/sklearn/hmm.py
+++ b/sklearn/hmm.py
@@ -560,12 +560,15 @@ def _accumulate_sufficient_statistics(self, stats, seq, framelogprob,
             stats['start'] += posteriors[0]
         if 't' in params:
             n_observations, n_components = framelogprob.shape
-            lneta = np.zeros((n_observations - 1, n_components, n_components))
-            lnP = logsumexp(fwdlattice[-1])
-            _hmmc._compute_lneta(n_observations, n_components, fwdlattice,
-                                 self._log_transmat, bwdlattice, framelogprob,
-                                 lnP, lneta)
-            stats["trans"] += np.exp(logsumexp(lneta, 0))
+            # when the sample is of length 1, it contains no transitions
+            # so there is no reason to update our trans. matrix estimate
+            if n_observations > 1:
+                lneta = np.zeros((n_observations - 1, n_components, n_components))
+                lnP = logsumexp(fwdlattice[-1])
+                _hmmc._compute_lneta(n_observations, n_components, fwdlattice,
+                                     self._log_transmat, bwdlattice, framelogprob,
+                                     lnP, lneta)
+                stats["trans"] += np.exp(logsumexp(lneta, 0))
 
     def _do_mstep(self, stats, params):
         # Based on Huang, Acero, Hon, "Spoken Language Processing",
diff --git a/sklearn/tests/test_hmm.py b/sklearn/tests/test_hmm.py
index a3aaea5a6adeb..2869bc456ea5c 100644
--- a/sklearn/tests/test_hmm.py
+++ b/sklearn/tests/test_hmm.py
@@ -312,6 +312,16 @@ def test_fit_works_on_sequences_of_different_length(self):
         # ValueError: setting an array element with a sequence.
         h.fit(obs)
 
+    def test_fit_with_length_one_signal(self):
+        obs = [self.prng.rand(10, self.n_features),
+               self.prng.rand(8, self.n_features),
+               self.prng.rand(1, self.n_features)]
+        h = hmm.GaussianHMM(self.n_components, self.covariance_type)
+        # This shouldn't raise
+        # ValueError: zero-size array to reduction operation maximum which has no identity
+        h.fit(obs)
+
+
     def test_fit_with_priors(self, params='stmc', n_iter=5, verbose=False):
         startprob_prior = 10 * self.startprob + 2.0
         transmat_prior = 10 * self.transmat + 2.0

Here's the bug report:

https://github.com/scikit-learn/scikit-learn/issues/1817#issuecomment-17340048
