Skip to content

Commit

Permalink
Fix test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer committed Oct 30, 2024
1 parent 41f1446 commit 08ad7f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
# Skip tests triggering to-be-investigated fatal error on Windows :(
(
if [[ "$(python -c 'import sys; print(sys.platform)')" != win32 ]]; then
./run-mpl-test-suite.py --tolerance=50 --instafail --timeout=300 --capture=no --verbose
./run-mpl-test-suite.py --tolerance=55 --instafail --timeout=300 --capture=no --verbose
fi
) &&
PYTHONFAULTHANDLER=1 PYTHONIOENCODING=utf-8 ./run-examples.py
Expand Down
8 changes: 8 additions & 0 deletions ISSUES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ There is a significant performance regression on the wire3d_animation example.
Fix needed
==========

test_backend_ps
test_savefig_to_stringio[ps with distiller=xpdf-landscape-letter]
xpdf output differences?

test_ft2font
test_fallback_missing
Font fallback is not implemented.

test_image
test_figimage[pdf], test_figimage0[pdf], test_figimage1[pdf], test_interp_nearest_vs_none[pdf,svg], test_rasterize_dpi[pdf,svg]
Invalid dpi manipulations in vector output.
Expand Down
10 changes: 10 additions & 0 deletions run-mpl-test-suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def pytest_collection_modifyitems(session, config, items):
"matplotlib/tests/" + nodeid: marker
for marker, nodeids in [
(knownfail, [
# Unclear why xpdf doesn't output DocumentMedia: Letter ... for us.
"test_backend_ps.py::test_savefig_to_stringio[ps with distiller=xpdf-landscape-letter]",
"test_ft2font.py::test_fallback_missing[",
"test_image.py::test_jpeg_alpha",
"test_image.py::test_figimage[pdf-False]",
"test_image.py::test_figimage[pdf-True]",
Expand Down Expand Up @@ -171,6 +174,11 @@ def pytest_collection_modifyitems(session, config, items):
"test_backend_ps.py::test_savefig_to_stringio[eps-portrait]",
"test_backend_ps.py::test_savefig_to_stringio[eps afm-landscape]",
"test_backend_ps.py::test_savefig_to_stringio[eps afm-portrait]",
# We don't need to distill (unless requested) for PS+usetex.
"test_backend_ps.py::test_savefig_to_stringio[ps with usetex-landscape-figure]",
"test_backend_ps.py::test_savefig_to_stringio[ps with usetex-landscape-letter]",
"test_backend_ps.py::test_savefig_to_stringio[ps with usetex-portrait-figure]",
"test_backend_ps.py::test_savefig_to_stringio[ps with usetex-portrait-letter]",
# cairo doesn't support SOURCE_DATE_EPOCH.
"test_backend_ps.py::test_source_date_epoch",
# Useful, but the tag structure is too different (e.g. cairo
Expand All @@ -194,6 +202,8 @@ def pytest_collection_modifyitems(session, config, items):
# Different tight bbox.
"test_bbox_tight.py::test_bbox_inches_tight_suptile_legend[",
"test_bbox_tight.py::test_bbox_inches_tight_suptitle_non_default[",
# Labels placed differently due to different label size.
"test_contour.py::test_label_contour_start",
# We already raise on invalid savefig kwargs.
"test_figure.py::test_savefig_warns",
# cairo uses a different representation for ps images (but
Expand Down
8 changes: 6 additions & 2 deletions src/mplcairo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ def _print_ps_impl(self, is_eps, path_or_stream, *,
**kwargs):
if papertype is None:
papertype = mpl.rcParams["ps.papersize"]
if papertype == "auto" and not hasattr(backend_ps, "_get_papertype"):
with mpl.rc_context({"ps.papersize": "auto"}):
pass # Trigger ValueError in mpl>=3.10.
if orientation == "portrait":
if papertype == "auto":
width, height = self.figure.get_size_inches()
Expand All @@ -337,12 +340,13 @@ def _print_ps_impl(self, is_eps, path_or_stream, *,
if "Title" in metadata:
dsc_comments.append("%%Title: {}".format(metadata.pop("Title")))
fig_wh = self.figure.get_size_inches() * np.array(72)
if orientation == "landscape":
fig_wh = fig_wh[::-1]
if not is_eps and papertype != "figure":
dsc_comments.append(f"%%DocumentPaperSizes: {papertype}")
paper_wh = backend_ps.papersize[papertype] * np.array(72)
if orientation == "landscape":
paper_wh = paper_wh[::-1]
fig_wh = fig_wh[::-1]
offset = (paper_wh - fig_wh) / 2 * [1, -1]
# FIXME: We should set the init transform, including the rotation
# for landscape orientation, instead of just the offset.
Expand All @@ -361,7 +365,7 @@ def _print_ps_impl(self, is_eps, path_or_stream, *,
"xpdf": backend_ps.xpdf_distill}[
mpl.rcParams["ps.usedistiller"]](
str(tmp_name), is_eps, ptype=papertype,
# Assume we can get away with just bbox width/height.
# Assume we can get away with just bbox width/height.
bbox=(None, None, *fig_wh))
# If path_or_stream is *already* a text-mode stream then
# tmp_name needs to be opened in text-mode too.
Expand Down

0 comments on commit 08ad7f8

Please sign in to comment.