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

Skip to content

Commit 3edc982

Browse files
committed
cairo: Don't copy the ravelled image.
flatten() always makes a copy, whereas ravel() does not.
1 parent fb17040 commit 3edc982

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
@@ -233,12 +233,12 @@ def draw_image(self, gc, x, y, im):
233233
# on ctypes to get a pointer to the numpy array. This works
234234
# correctly on a numpy array in python3 but not 2.7. We replicate
235235
# the array.array functionality here to get cross version support.
236-
imbuffer = ArrayWrapper(im.flatten())
236+
imbuffer = ArrayWrapper(im.ravel())
237237
else:
238-
# pycairo uses PyObject_AsWriteBuffer to get a pointer to the
238+
# py2cairo uses PyObject_AsWriteBuffer to get a pointer to the
239239
# numpy array; this works correctly on a regular numpy array but
240-
# not on a py2 memoryview.
241-
imbuffer = im.flatten()
240+
# not on a memory view.
241+
imbuffer = im.ravel()
242242
surface = cairo.ImageSurface.create_for_data(
243243
imbuffer, cairo.FORMAT_ARGB32,
244244
im.shape[1], im.shape[0], im.shape[1]*4)

0 commit comments

Comments
 (0)