Skip to content

Commit e736aa3

Browse files
authored
Merge pull request #226 from hyanwong/fix-warnings
Don't warn when we expect np.log(0) to occur
2 parents 34daeeb + c45d463 commit e736aa3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/test_functions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,15 @@ def test_logsumexp(self):
742742
assert np.allclose(LogLikelihoods.logsumexp(log_lls), np.log(ll_sum))
743743

744744
def test_zeros_logsumexp(self):
745-
lls = np.log(np.concatenate([np.zeros(100), np.random.rand(1000)]))
746-
assert np.allclose(LogLikelihoods.logsumexp(lls), self.naive_logsumexp(lls))
745+
with np.errstate(divide="ignore"):
746+
lls = np.log(np.concatenate([np.zeros(100), np.random.rand(1000)]))
747+
assert np.allclose(LogLikelihoods.logsumexp(lls), self.naive_logsumexp(lls))
747748

748749
def test_logsumexp_underflow(self):
749750
# underflow in the naive case, but not in the LogLikelihoods implementation
750751
lls = np.array([-1000, -1001])
751-
assert self.naive_logsumexp(lls) == -np.inf
752+
with np.errstate(divide="ignore"):
753+
assert self.naive_logsumexp(lls) == -np.inf
752754
assert LogLikelihoods.logsumexp(lls) != -np.inf
753755

754756
def test_log_tri_functions(self):

0 commit comments

Comments
 (0)