Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cabc4a3

Browse files
committed
Replace bivariate normal in testing methods
1 parent e5f265a commit cabc4a3

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lib/matplotlib/mlab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ def derivs(x,t):
18731873
return yout
18741874

18751875

1876+
@cbook.deprecated('2.2')
18761877
def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0,
18771878
mux=0.0, muy=0.0, sigmaxy=0.0):
18781879
"""

lib/matplotlib/tests/test_contour.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datetime
55

66
import numpy as np
7-
from matplotlib import mlab
87
from matplotlib.testing.decorators import image_comparison
98
from matplotlib import pyplot as plt
109
from numpy.testing import assert_array_almost_equal
@@ -243,8 +242,10 @@ def test_labels():
243242
x = np.arange(-3.0, 3.0, delta)
244243
y = np.arange(-2.0, 2.0, delta)
245244
X, Y = np.meshgrid(x, y)
246-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
247-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
245+
Z1 = np.exp(-(X**2 + Y**2) / 2) / (2 * np.pi)
246+
Z2 = (np.exp(-(((X - 1) / 1.5)**2 + ((Y - 1) / 0.5)**2) / 2) /
247+
(2 * np.pi * 0.5 * 1.5))
248+
248249
# difference of Gaussians
249250
Z = 10.0 * (Z2 - Z1)
250251

lib/matplotlib/tests/test_image.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,9 @@ def test_rotate_image():
608608
delta = 0.25
609609
x = y = np.arange(-3.0, 3.0, delta)
610610
X, Y = np.meshgrid(x, y)
611-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
612-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
611+
Z1 = np.exp(-(X**2 + Y**2) / 2) / (2 * np.pi)
612+
Z2 = (np.exp(-(((X - 1) / 1.5)**2 + ((Y - 1) / 0.5)**2) / 2) /
613+
(2 * np.pi * 0.5 * 1.5))
613614
Z = Z2 - Z1 # difference of Gaussians
614615

615616
fig, ax1 = plt.subplots(1, 1)
@@ -670,8 +671,9 @@ def test_mask_image_over_under():
670671
delta = 0.025
671672
x = y = np.arange(-3.0, 3.0, delta)
672673
X, Y = np.meshgrid(x, y)
673-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
674-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
674+
Z1 = np.exp(-(X**2 + Y**2) / 2) / (2 * np.pi)
675+
Z2 = (np.exp(-(((X - 1) / 1.5)**2 + ((Y - 1) / 0.5)**2) / 2) /
676+
(2 * np.pi * 0.5 * 1.5))
675677
Z = 10*(Z2 - Z1) # difference of Gaussians
676678

677679
palette = copy(plt.cm.gray)

0 commit comments

Comments
 (0)