Skip to content

Commit 2655fde

Browse files
committed
Silence divide by zero warning from np.log(0) in test. Inspired by how scipy tests does.
1 parent ae1e230 commit 2655fde

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ def test_hexbin_extent():
374374
@image_comparison(baseline_images=['nonfinite_limits'])
375375
def test_nonfinite_limits():
376376
x = np.arange(0., np.e, 0.01)
377-
y = np.log(x)
377+
olderr = np.seterr(divide='ignore') #silence divide by zero warning from log(0)
378+
try:
379+
y = np.log(x)
380+
finally:
381+
np.seterr(**olderr)
378382
x[len(x)/2] = np.nan
379383
fig = plt.figure()
380384
ax = fig.add_subplot(111)

0 commit comments

Comments
 (0)