Skip to content

Commit baeb6de

Browse files
committed
Updated test, and added a check for tuple length
1 parent 04ee71e commit baeb6de

File tree

5 files changed

+66
-108
lines changed

5 files changed

+66
-108
lines changed
Binary file not shown.
-6.54 KB
Loading

lib/matplotlib/tests/baseline_images/test_image/image_composite_alpha.svg

Lines changed: 49 additions & 97 deletions
Loading

lib/matplotlib/tests/test_image.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,22 @@ def test_image_composite_alpha():
243243
"""
244244
fig = plt.figure()
245245
ax = fig.add_subplot(111)
246-
arr = np.arange(12).reshape(4, 3)
247-
ax.imshow(arr, extent=[0, 2, 15, 0], alpha=0.25)
248-
ax.imshow(arr, extent=[4, 6, 15, 0], alpha=0.5)
249-
ax.imshow(arr, extent=[8, 10, 15, 0])
250-
ax.imshow(arr.T, extent=[0, 12, 2, 4], alpha=0.25)
251-
ax.imshow(arr.T, extent=[0, 12, 6, 8], alpha=0.5)
252-
ax.imshow(arr.T, extent=[0, 12, 10, 12], alpha=1.0)
253-
ax.set_axis_bgcolor((0, 0, 0, 0.5))
254-
ax.set_xlim([0, 12])
255-
ax.set_ylim([15, 0])
246+
arr = np.zeros((11, 21, 4))
247+
arr[:, :, 0] = 1
248+
arr[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))
249+
arr2 = np.zeros((21, 11, 4))
250+
arr2[:, :, 0] = 1
251+
arr2[:, :, 1] = 1
252+
arr2[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))[:, np.newaxis]
253+
ax.imshow(arr, extent=[1, 2, 5, 0], alpha=0.3)
254+
ax.imshow(arr, extent=[2, 3, 5, 0], alpha=0.6)
255+
ax.imshow(arr, extent=[3, 4, 5, 0])
256+
ax.imshow(arr2, extent=[0, 5, 1, 2])
257+
ax.imshow(arr2, extent=[0, 5, 2, 3], alpha=0.6)
258+
ax.imshow(arr2, extent=[0, 5, 3, 4], alpha=0.3)
259+
ax.set_axis_bgcolor((0, 0.5, 0, 1))
260+
ax.set_xlim([0, 5])
261+
ax.set_ylim([5, 0])
256262

257263

258264
if __name__=='__main__':

src/_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ _image_module::from_images(const Py::Tuple& args)
825825
Image* thisim = static_cast<Image*>(tup[0].ptr());
826826
ox = (long)Py::Int(tup[1]);
827827
oy = (long)Py::Int(tup[2]);
828-
if (tup[3].ptr() == Py_None)
828+
if (tup.size() <= 3 || tup[3].ptr() == Py_None)
829829
{
830830
apply_alpha = false;
831831
}

0 commit comments

Comments
 (0)