Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Updated test, and added a check for tuple length
  • Loading branch information
Westacular committed May 8, 2013
commit baeb6de888b9f7090dbae803465e9a1615d36d97
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,22 @@ def test_image_composite_alpha():
"""
fig = plt.figure()
ax = fig.add_subplot(111)
arr = np.arange(12).reshape(4, 3)
ax.imshow(arr, extent=[0, 2, 15, 0], alpha=0.25)
ax.imshow(arr, extent=[4, 6, 15, 0], alpha=0.5)
ax.imshow(arr, extent=[8, 10, 15, 0])
ax.imshow(arr.T, extent=[0, 12, 2, 4], alpha=0.25)
ax.imshow(arr.T, extent=[0, 12, 6, 8], alpha=0.5)
ax.imshow(arr.T, extent=[0, 12, 10, 12], alpha=1.0)
ax.set_axis_bgcolor((0, 0, 0, 0.5))
ax.set_xlim([0, 12])
ax.set_ylim([15, 0])
arr = np.zeros((11, 21, 4))
arr[:, :, 0] = 1
arr[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))
arr2 = np.zeros((21, 11, 4))
arr2[:, :, 0] = 1
arr2[:, :, 1] = 1
arr2[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))[:, np.newaxis]
ax.imshow(arr, extent=[1, 2, 5, 0], alpha=0.3)
ax.imshow(arr, extent=[2, 3, 5, 0], alpha=0.6)
ax.imshow(arr, extent=[3, 4, 5, 0])
ax.imshow(arr2, extent=[0, 5, 1, 2])
ax.imshow(arr2, extent=[0, 5, 2, 3], alpha=0.6)
ax.imshow(arr2, extent=[0, 5, 3, 4], alpha=0.3)
ax.set_axis_bgcolor((0, 0.5, 0, 1))
ax.set_xlim([0, 5])
ax.set_ylim([5, 0])


if __name__=='__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ _image_module::from_images(const Py::Tuple& args)
Image* thisim = static_cast<Image*>(tup[0].ptr());
ox = (long)Py::Int(tup[1]);
oy = (long)Py::Int(tup[2]);
if (tup[3].ptr() == Py_None)
if (tup.size() <= 3 || tup[3].ptr() == Py_None)
{
apply_alpha = false;
}
Expand Down