pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/46b51236a4891bee881f29574df0073f9b16eaf4

ss" /> Merge remote-tracking branch 'upstream/v1.3.x' · matplotlib/matplotlib@46b5123 · GitHub
Skip to content

Commit 46b5123

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
Conflicts: lib/matplotlib/tests/test_backend_pdf.py
2 parents 912579a + e85f1c3 commit 46b5123

5 files changed

Lines changed: 29 additions & 15 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ script:
3636

3737
after_failure:
3838
- cd ../matplotlib
39-
- ./travis_upload.sh
39+
- tar cjf result_images.tar.bz2 result_images
40+
- travis-artifacts upload --path result_images.tar.bz2
41+
- echo https://s3.amazonaws.com/matplotlib-test-results/artifacts/${TRAVIS_BUILD_NUMBER}/${TRAVIS_JOB_NUMBER}/result_images.tar.bz2

lib/matplotlib/backends/backend_pdf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,12 @@ def savefig(self, figure=None, **kwargs):
23142314
else:
23152315
figureManager.canvas.figure.savefig(self, format='pdf', **kwargs)
23162316

2317+
def get_pagecount(self):
2318+
"""
2319+
Returns the current number of pages in the multipage pdf file.
2320+
"""
2321+
return len(self._file.pageList)
2322+
23172323
class FigureCanvasPdf(FigureCanvasBase):
23182324
"""
23192325
The canvas the figure renders into. Calls the draw and print fig

lib/matplotlib/tests/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def setup():
1515
# it during all of the tests.
1616
import locale
1717
import warnings
18+
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
1819

1920
try:
2021
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
@@ -36,6 +37,12 @@ def setup():
3637
rcParams['text.hinting'] = False
3738
rcParams['text.hinting_factor'] = 8
3839

40+
# Clear the font caches. Otherwise, the hinting mode can travel
41+
# from one test to another.
42+
backend_agg.RendererAgg._fontd.clear()
43+
backend_pdf.RendererPdf.truetype_font_cache.clear()
44+
backend_svg.RendererSVG.fontd.clear()
45+
3946

4047
def assert_str_equal(reference_str, test_str,
4148
format_str=('String {str1} and {str2} do not '

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def test_type42():
3737
fig.savefig(io.BytesIO())
3838

3939

40-
if __name__ == "__main__":
41-
import nose
42-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
40+
@cleanup
41+
def test_multipage_pagecount():
42+
from matplotlib.backends.backend_pdf import PdfPages
43+
from io import BytesIO
44+
with PdfPages(BytesIO()) as pdf:
45+
assert pdf.get_pagecount() == 0
46+
fig = plt.figure()
47+
ax = fig.add_subplot(111)
48+
ax.plot([1, 2, 3])
49+
fig.savefig(pdf, format="pdf")
50+
assert pdf.get_pagecount() == 1
51+
pdf.savefig()
52+
assert pdf.get_pagecount() == 2

travis_upload.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy