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

Skip to content

Commit 268c372

Browse files
authored
Merge pull request #13629 from anntzer/outer
Small example simplification.
2 parents 7a4bf2b + 660b81d commit 268c372

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/images_contours_and_fields/image_transparency_blend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
First we will generate some data, in this case, we'll create two 2-D "blobs"
1717
in a 2-D grid. One blob will be positive, and the other negative.
1818
"""
19+
1920
# sphinx_gallery_thumbnail_number = 3
2021
import numpy as np
2122
import matplotlib.pyplot as plt
@@ -43,9 +44,8 @@ def normal_pdf(x, mean, var):
4344
gauss_x_low = normal_pdf(xx, means_low[0], var[1])
4445
gauss_y_low = normal_pdf(yy, means_low[1], var[1])
4546

46-
weights_high = np.array(np.meshgrid(gauss_x_high, gauss_y_high)).prod(0)
47-
weights_low = -1 * np.array(np.meshgrid(gauss_x_low, gauss_y_low)).prod(0)
48-
weights = weights_high + weights_low
47+
weights = (np.outer(gauss_y_high, gauss_x_high)
48+
- np.outer(gauss_y_low, gauss_x_low))
4949

5050
# We'll also create a grey background into which the pixels will fade
5151
greys = np.full((*weights.shape, 3), 70, dtype=np.uint8)

0 commit comments

Comments
 (0)