diff --git a/CHANGES.rst b/CHANGES.rst index 24a1eb62..fcd5e8d2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,13 @@ hmmlearn Changelog Here you can see the full list of changes between each hmmlearn release. +next +---- + +- Removed the deprecated ``iter_from_X_lengths`` and ``log_mask_zero``; + ``lengths`` arrays that do not sum up to the entire array length are no + longer supported. + Version 0.2.8 ------------- diff --git a/lib/hmmlearn/_utils.py b/lib/hmmlearn/_utils.py index cd86782f..5b2ad8c6 100644 --- a/lib/hmmlearn/_utils.py +++ b/lib/hmmlearn/_utils.py @@ -1,7 +1,5 @@ """Private utilities.""" -import warnings - import numpy as np from sklearn.utils.validation import NotFittedError @@ -12,14 +10,9 @@ def split_X_lengths(X, lengths): else: cs = np.cumsum(lengths) n_samples = len(X) - if cs[-1] > n_samples: + if cs[-1] != n_samples: raise ValueError( - f"more than {n_samples} samples in lengths array {lengths}") - elif cs[-1] != n_samples: - warnings.warn( - f"less that {n_samples} samples in lengths array {lengths}; " - f"support for silently dropping samples is deprecated and " - f"will be removed", DeprecationWarning, stacklevel=3) + f"lengths array {lengths} doesn't sum to {n_samples} samples") return np.split(X, cs)[:-1] diff --git a/lib/hmmlearn/utils.py b/lib/hmmlearn/utils.py index f8bbb459..a080e561 100644 --- a/lib/hmmlearn/utils.py +++ b/lib/hmmlearn/utils.py @@ -1,5 +1,3 @@ -import warnings - import numpy as np from scipy import special @@ -57,43 +55,6 @@ def log_normalize(a, axis=None): a -= a_lse -def iter_from_X_lengths(X, lengths): - warnings.warn( - "iter_from_X_lengths is deprecated and will be removed in the future.", - DeprecationWarning, stacklevel=2) - if lengths is None: - yield 0, len(X) - else: - n_samples = X.shape[0] - end = np.cumsum(lengths).astype(np.int32) - start = end - lengths - if end[-1] > n_samples: - raise ValueError( - f"more than {n_samples} samples in lengths array {lengths}") - for i in range(len(lengths)): - yield start[i], end[i] - - -def log_mask_zero(a): - """ - Compute the log of input probabilities masking divide by zero in log. - - Notes - ----- - During the M-step of EM-algorithm, very small intermediate start - or transition probabilities could be normalized to zero, causing a - *RuntimeWarning: divide by zero encountered in log*. - - This function masks this unharmful warning. - """ - warnings.warn( - "log_mask_zero is deprecated and will be removed in the future.", - DeprecationWarning, stacklevel=2) - a = np.asarray(a) - with np.errstate(divide="ignore"): - return np.log(a) - - def fill_covars(covars, covariance_type='full', n_components=1, n_features=1): if covariance_type == 'full': return covars