Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ci: Re-add tests with optimization enabled#29549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
QuLogic wants to merge5 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromQuLogic:opt-tests
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions.github/workflows/tests.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,10 +56,11 @@ jobs:
pygobject-ver: '<3.52.0'
- os: ubuntu-22.04
python-version: '3.11'
CFLAGS: "-fno-lto" # Ensure that disabling LTO works.
lto: "--config-settings=setup-args=-Db_lto=false" # Ensure that disabling LTO works.
extra-requirements: '-r requirements/testing/extra.txt'
# https://github.com/matplotlib/matplotlib/issues/29844
pygobject-ver: '<3.52.0'
python-optimize: 'true'
- os: ubuntu-22.04-arm
python-version: '3.12'
# https://github.com/matplotlib/matplotlib/issues/29844
Expand DownExpand Up@@ -317,7 +318,7 @@ jobs:
fi

python -m pip install --no-deps --no-build-isolation --verbose \
--config-settings=setup-args="-DrcParams-backend=Agg" \
--config-settings=setup-args="-DrcParams-backend=Agg"${{ matrix.lto }}\
--editable .[dev]

if [[ "${{ runner.os }}" != 'macOS' ]]; then
Expand All@@ -334,7 +335,10 @@ jobs:
if [[ "${{ matrix.python-version }}" == '3.13t' ]]; then
export PYTHON_GIL=0
fi
pytest -rfEsXR -n auto \
if [[ "${{ matrix.python-optimize }}" == 'true' ]]; then
export PYTHONOPTIMIZE=2
fi
pytest -rfEsXR -n auto -sv \
--maxfail=50 --timeout=300 --durations=25 \
--cov-report=xml --cov=lib --log-level=DEBUG --color=yes

Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/testing/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -129,6 +129,8 @@ def subprocess_run_helper(func, *args, timeout, extra_env=None):
[
sys.executable,
"-c",
f"import pytest;"
f"pytest.register_assert_rewrite({module!r});"
f"import importlib.util;"
f"_spec = importlib.util.spec_from_file_location({module!r}, {file!r});"
f"_module = importlib.util.module_from_spec(_spec);"
Expand Down
7 changes: 6 additions & 1 deletionlib/matplotlib/tests/test_artist.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
import io
from itertools import chain
import sys

import numpy as np

Expand DownExpand Up@@ -256,7 +257,9 @@ def test_setp():
# Check *file* argument
sio = io.StringIO()
plt.setp(lines1, 'zorder', file=sio)
assert sio.getvalue() == ' zorder: float\n'
# With optimization, docstrings are stripped so the automated types don't work.
expected = 'unknown' if sys.flags.optimize >= 2 else 'float'
assert sio.getvalue() == f' zorder: {expected}\n'


def test_None_zorder():
Expand DownExpand Up@@ -361,6 +364,8 @@ def set_myparam2(self, val):
assert 'myparam2' in MyArtist2.set.__doc__


@pytest.mark.skipif(sys.flags.optimize >= 2,
reason='Python optimization is enabled and docstrings are stripped')
def test_set_is_overwritten():
"""set() defined in Artist subclasses should not be overwritten."""
class MyArtist3(martist.Artist):
Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/tests/test_backends_interactive.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -460,6 +460,8 @@
reason="$DISPLAY and $WAYLAND_DISPLAY are unset")
@pytest.mark.parametrize('host, mpl', [*qt5_and_qt6_pairs()])
def test_cross_Qt_imports(host, mpl):
if sys.flags.optimize > 0 and 'PySide2' in {host, mpl}:
pytest.xfail('PySide2 does not work optimized')

Check warning on line 464 in lib/matplotlib/tests/test_backends_interactive.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/tests/test_backends_interactive.py#L464

Added line #L464 was not covered by tests
try:
proc = _run_helper(_impl_test_cross_Qt_imports, host, mpl,
timeout=_test_timeout)
Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/tests/test_matplotlib.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,6 +44,8 @@ def test_importable_with_no_home(tmp_path):
env={**os.environ, "MPLCONFIGDIR": str(tmp_path)}, check=True)


@pytest.mark.skipif(sys.flags.optimize >= 2,
reason='Python optimization is enabled and docstrings are stripped')
def test_use_doc_standard_backends():
"""
Test that the standard backends mentioned in the docstring of
Expand Down
24 changes: 14 additions & 10 deletionslib/matplotlib/tests/test_preprocess_data.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,23 +39,25 @@ def func_no_ax_args(*args, **kwargs): pass
# this has "enough" information to do all the replaces
_preprocess_data(replace_names=["x", "y"])(func_args)

# no positional_parameter_names but needed due to replaces
with pytest.raises(AssertionError):
# z is unknown
_preprocess_data(replace_names=["x", "y", "z"])(func_args)

# no replacements at all -> all ok...
_preprocess_data(replace_names=[], label_namer=None)(func)
_preprocess_data(replace_names=[], label_namer=None)(func_args)
_preprocess_data(replace_names=[], label_namer=None)(func_kwargs)
_preprocess_data(replace_names=[], label_namer=None)(func_no_ax_args)

# label namer is unknown
with pytest.raises(AssertionError):
_preprocess_data(label_namer="z")(func)
# No asserts with optimizations.
if sys.flags.optimize < 1:
# no positional_parameter_names but needed due to replaces
with pytest.raises(AssertionError):
# z is unknown
_preprocess_data(replace_names=["x", "y", "z"])(func_args)

# label namer is unknown
with pytest.raises(AssertionError):
_preprocess_data(label_namer="z")(func)

with pytest.raises(AssertionError):
_preprocess_data(label_namer="z")(func_args)
with pytest.raises(AssertionError):
_preprocess_data(label_namer="z")(func_args)


@pytest.mark.parametrize('func', all_funcs, ids=all_func_ids)
Expand DownExpand Up@@ -193,6 +195,8 @@ def func(ax, x, y, z=1):
func(None, "a", "b", "z", "z", data=data)


@pytest.mark.skipif(sys.flags.optimize >= 2,
reason='Python optimization is enabled and docstrings are stripped')
def test_docstring_addition():
@_preprocess_data()
def funcy(ax, *args, **kwargs):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp