Skip to content

Commit

Permalink
Expire deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Dec 30, 2022
1 parent 7214c0a commit 83edce2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 48 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------

Expand Down
11 changes: 2 additions & 9 deletions lib/hmmlearn/_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Private utilities."""

import warnings

import numpy as np
from sklearn.utils.validation import NotFittedError

Expand All @@ -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]


Expand Down
39 changes: 0 additions & 39 deletions lib/hmmlearn/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import numpy as np
from scipy import special

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83edce2

Please sign in to comment.