Skip to content

Commit ba40160

Browse files
committed
Remove use of PyCXX in core C++ extensions
1 parent dbeed94 commit ba40160

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+9880
-10054
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ matrix:
2424

2525
install:
2626
- pip install -q --use-mirrors nose python-dateutil $NUMPY pep8 pyparsing pillow
27-
- sudo apt-get update && sudo apt-get -qq install inkscape libav-tools
28-
# We use --no-install-recommends to avoid pulling in additional large latex docs that we don't need
27+
- sudo apt-get update && sudo apt-get -qq install inkscape libav-tools gdb
28+
# We use --no-install-recommends to avoid pulling in additional large latex docs that we don't need
2929
- if [[ $BUILD_DOCS == true ]]; then sudo apt-get install -qq --no-install-recommends dvipng texlive-latex-base texlive-latex-extra texlive-fonts-recommended graphviz; fi
3030
- if [[ $BUILD_DOCS == true ]]; then pip install sphinx numpydoc linkchecker; fi
3131
- python setup.py install
@@ -37,11 +37,12 @@ script:
3737
- echo Testing using 8 processes
3838
# Generate the font caches in a single process before starting the
3939
# multiple processes
40+
- gcc --version
4041
- python -c "from matplotlib import font_manager"
4142
- if [[ $BUILD_DOCS == false ]]; then export MPL_REPO_DIR=$PWD; fi # pep8-conformance test of the examples
4243
- if [[ $BUILD_DOCS == false ]]; then mkdir ../tmp_test_dir; fi
4344
- if [[ $BUILD_DOCS == false ]]; then cd ../tmp_test_dir; fi
44-
- if [[ $BUILD_DOCS == false ]]; then python ../matplotlib/tests.py -sv --processes=8 --process-timeout=300 $TEST_ARGS; fi
45+
- if [[ $BUILD_DOCS == false ]]; then gdb -return-child-result -batch -ex r -ex bt --args python ../matplotlib/tests.py -sv $TEST_ARGS; fi
4546
- if [[ $BUILD_DOCS == true ]]; then cd doc; python make.py html --small; fi
4647
# We don't build the LaTeX docs here, so linkchecker will complain
4748
- if [[ $BUILD_DOCS == true ]]; then touch build/html/Matplotlib.pdf; fi

examples/pylab_examples/agg_buffer_to_array.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
fig.canvas.draw()
99

1010
# grab the pixel buffer and dump it into a numpy array
11-
buf = fig.canvas.buffer_rgba()
12-
l, b, w, h = fig.bbox.bounds
13-
# The array needs to be copied, because the underlying buffer
14-
# may be reallocated when the window is resized.
15-
X = np.frombuffer(buf, np.uint8).copy()
16-
X.shape = h,w,4
11+
X = np.array(fig.canvas.renderer._renderer)
1712

1813
# now display the array X as an Axes in a new figure
1914
fig2 = plt.figure()

examples/pylab_examples/mathtext_demo.py

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@
2424

2525
ax.set_title(r'$\Delta_i^j \hspace{0.4} \mathrm{versus} \hspace{0.4} \Delta_{i+1}^j$', fontsize=20)
2626

27-
2827
show()

lib/matplotlib/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,13 @@ def tk_window_focus():
14051405

14061406
def test(verbosity=1):
14071407
"""run the matplotlib test suite"""
1408+
try:
1409+
import faulthandler
1410+
except ImportError:
1411+
pass
1412+
else:
1413+
faulthandler.enable()
1414+
14081415
old_backend = rcParams['backend']
14091416
try:
14101417
use('agg')

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,8 +2063,8 @@ def draw(self, renderer=None, inframe=False):
20632063
for z, im in zorder_images]
20642064

20652065
l, b, r, t = self.bbox.extents
2066-
width = mag * ((round(r) + 0.5) - (round(l) - 0.5))
2067-
height = mag * ((round(t) + 0.5) - (round(b) - 0.5))
2066+
width = int(mag * ((round(r) + 0.5) - (round(l) - 0.5)))
2067+
height = int(mag * ((round(t) + 0.5) - (round(b) - 0.5)))
20682068
im = mimage.from_images(height,
20692069
width,
20702070
ims)

lib/matplotlib/backends/backend_agg.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,19 @@ def draw_path_collection(self, *kl, **kw):
127127
return self._renderer.draw_path_collection(*kl, **kw)
128128

129129
def _update_methods(self):
130-
#self.draw_path = self._renderer.draw_path # see below
131-
#self.draw_markers = self._renderer.draw_markers
132-
#self.draw_path_collection = self._renderer.draw_path_collection
133130
self.draw_quad_mesh = self._renderer.draw_quad_mesh
134131
self.draw_gouraud_triangle = self._renderer.draw_gouraud_triangle
135132
self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles
136133
self.draw_image = self._renderer.draw_image
137134
self.copy_from_bbox = self._renderer.copy_from_bbox
138-
self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized
135+
self.get_content_extents = self._renderer.get_content_extents
136+
137+
def tostring_rgba_minimized(self):
138+
extents = self.get_content_extents()
139+
bbox = [[extents[0], self.height - (extents[1] + extents[3])],
140+
[extents[0] + extents[2], self.height - extents[1]]]
141+
region = self.copy_from_bbox(bbox)
142+
return np.array(region), extents
139143

140144
def draw_path(self, gc, path, transform, rgbFace=None):
141145
"""
@@ -203,7 +207,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
203207

204208
#print x, y, int(x), int(y), s
205209
self._renderer.draw_text_image(
206-
font.get_image(), np.round(x - xd), np.round(y + yd) + 1, angle, gc)
210+
font, np.round(x - xd), np.round(y + yd) + 1, angle, gc)
207211

208212
def get_text_width_height_descent(self, s, prop, ismath):
209213
"""
@@ -354,7 +358,7 @@ def restore_region(self, region, bbox=None, xy=None):
354358
else:
355359
ox, oy = xy
356360

357-
self._renderer.restore_region2(region, x1, y1, x2, y2, ox, oy)
361+
self._renderer.restore_region(region, x1, y1, x2, y2, ox, oy)
358362

359363
else:
360364
self._renderer.restore_region(region)
@@ -394,7 +398,7 @@ def post_processing(image, dpi):
394398

395399
width, height = int(self.width), int(self.height)
396400

397-
buffer, bounds = self._renderer.tostring_rgba_minimized()
401+
buffer, bounds = self.tostring_rgba_minimized()
398402

399403
l, b, w, h = bounds
400404

@@ -407,7 +411,6 @@ def post_processing(image, dpi):
407411
img, ox, oy = post_processing(img.reshape((h, w, 4)) / 255.,
408412
self.dpi)
409413
image = fromarray(img, 1)
410-
image.flipud_out()
411414

412415
gc = self.new_gc()
413416
self._renderer.draw_image(gc,
@@ -505,12 +508,13 @@ def print_raw(self, filename_or_obj, *args, **kwargs):
505508
original_dpi = renderer.dpi
506509
renderer.dpi = self.figure.dpi
507510
if is_string_like(filename_or_obj):
508-
filename_or_obj = open(filename_or_obj, 'wb')
511+
fileobj = open(filename_or_obj, 'wb')
509512
close = True
510513
else:
514+
fileobj = filename_or_obj
511515
close = False
512516
try:
513-
renderer._renderer.write_rgba(filename_or_obj)
517+
fileobj.write(renderer._renderer.buffer_rgba())
514518
finally:
515519
if close:
516520
filename_or_obj.close()
@@ -528,9 +532,7 @@ def print_png(self, filename_or_obj, *args, **kwargs):
528532
else:
529533
close = False
530534
try:
531-
_png.write_png(renderer._renderer.buffer_rgba(),
532-
renderer.width, renderer.height,
533-
filename_or_obj, self.figure.dpi)
535+
_png.write_png(renderer._renderer, filename_or_obj, self.figure.dpi)
534536
finally:
535537
if close:
536538
filename_or_obj.close()

lib/matplotlib/backends/backend_cairo.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ def draw_image(self, gc, x, y, im):
167167
# bbox - not currently used
168168
if _debug: print('%s.%s()' % (self.__class__.__name__, _fn_name()))
169169

170-
im.flipud_out()
171-
172170
rows, cols, buf = im.color_conv (BYTE_FORMAT)
173171
surface = cairo.ImageSurface.create_for_data (
174172
buf, cairo.FORMAT_ARGB32, cols, rows, cols*4)
@@ -183,8 +181,6 @@ def draw_image(self, gc, x, y, im):
183181
ctx.paint()
184182
ctx.restore()
185183

186-
im.flipud_out()
187-
188184
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
189185
# Note: x,y are device/display coords, not user-coords, unlike other
190186
# draw_* methods

lib/matplotlib/backends/backend_gdk.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ def draw_image(self, gc, x, y, im):
109109
# int(w), int(h))
110110
# set clip rect?
111111

112-
im.flipud_out()
113112
rows, cols, image_str = im.as_rgba_str()
114113

115114
image_array = np.fromstring(image_str, np.uint8)
@@ -120,7 +119,7 @@ def draw_image(self, gc, x, y, im):
120119
width=cols, height=rows)
121120

122121
array = pixbuf_get_pixels_array(pixbuf)
123-
array[:,:,:] = image_array
122+
array[:,:,:] = image_array[::-1]
124123

125124
gc = self.new_gc()
126125

@@ -138,9 +137,6 @@ def draw_image(self, gc, x, y, im):
138137
int(x), int(y), cols, rows,
139138
gdk.RGB_DITHER_NONE, 0, 0)
140139

141-
# unflip
142-
im.flipud_out()
143-
144140

145141
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
146142
x, y = int(x), int(y)

lib/matplotlib/backends/backend_macosx.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ def get_image_magnification(self):
110110
return self.gc.get_image_magnification()
111111

112112
def draw_image(self, gc, x, y, im):
113-
im.flipud_out()
114113
nrows, ncols, data = im.as_rgba_str()
115114
gc.draw_image(x, y, nrows, ncols, data)
116-
im.flipud_out()
117115

118116
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
119117
# todo, handle props, angle, origins

lib/matplotlib/backends/backend_mixed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def stop_rasterizing(self):
121121
if w > 0 and h > 0:
122122
image = frombuffer(buffer, w, h, True)
123123
image.is_grayscale = False
124-
image.flipud_out()
125124
gc = self._renderer.new_gc()
126125
# TODO: If the mixedmode resolution differs from the figure's
127126
# dpi, the image must be scaled (dpi->_figdpi). Not all

0 commit comments

Comments
 (0)