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

Skip to content

Commit 2a28e01

Browse files
committed
cairo: Don't copy the ravelled image.
flatten() always makes a copy, whereas ravel() does not.
1 parent 8d53ebf commit 2a28e01

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ def draw_image(self, gc, x, y, im):
216216
# on ctypes to get a pointer to the numpy array. This works
217217
# correctly on a numpy array in python3 but not 2.7. We replicate
218218
# the array.array functionality here to get cross version support.
219-
imbuffer = ArrayWrapper(im.flatten())
219+
imbuffer = ArrayWrapper(im.ravel())
220220
else:
221-
# pycairo uses PyObject_AsWriteBuffer to get a pointer to the
221+
# py2cairo uses PyObject_AsWriteBuffer to get a pointer to the
222222
# numpy array; this works correctly on a regular numpy array but
223-
# not on a py2 memoryview.
224-
imbuffer = im.flatten()
223+
# not on a memory view.
224+
imbuffer = im.ravel()
225225
surface = cairo.ImageSurface.create_for_data(
226226
imbuffer, cairo.FORMAT_ARGB32,
227227
im.shape[1], im.shape[0], im.shape[1]*4)

0 commit comments

Comments
 (0)