Skip to content
Snippets Groups Projects
Unverified Commit 1b5b2dcf authored by Thomas Baumann's avatar Thomas Baumann Committed by GitHub
Browse files

Make plot helper compatible with Python 3.13 (#549)

parent 8f9bf8c6
No related branches found
No related tags found
No related merge requests found
Pipeline #283021 passed
import matplotlib as mpl import matplotlib as mpl
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from distutils.spawn import find_executable import shutil
default_mpl_params = mpl.rcParams.copy() default_mpl_params = mpl.rcParams.copy()
...@@ -100,7 +100,7 @@ def setup_mpl(font_size=8, reset=False): ...@@ -100,7 +100,7 @@ def setup_mpl(font_size=8, reset=False):
mpl.rcParams.update(style_options) mpl.rcParams.update(style_options)
if find_executable('latex'): if shutil.which('latex'):
latex_support = { latex_support = {
"pgf.texsystem": "pdflatex", # change this if using xetex or lautex "pgf.texsystem": "pdflatex", # change this if using xetex or lautex
"text.usetex": True, # use LaTeX to write all text "text.usetex": True, # use LaTeX to write all text
...@@ -125,7 +125,7 @@ def newfig(textwidth, scale, ratio=0.6180339887): ...@@ -125,7 +125,7 @@ def newfig(textwidth, scale, ratio=0.6180339887):
def savefig(filename, save_pdf=True, save_pgf=True, save_png=True): def savefig(filename, save_pdf=True, save_pgf=True, save_png=True):
if save_pgf and find_executable('latex'): if save_pgf and shutil.which('latex'):
plt.savefig('{}.pgf'.format(filename), bbox_inches='tight') plt.savefig('{}.pgf'.format(filename), bbox_inches='tight')
if save_pdf: if save_pdf:
plt.savefig('{}.pdf'.format(filename), bbox_inches='tight') plt.savefig('{}.pdf'.format(filename), bbox_inches='tight')
......
...@@ -25,6 +25,7 @@ def test_benchmark_collocation(benchmark): ...@@ -25,6 +25,7 @@ def test_benchmark_collocation(benchmark):
benchmark(wrapper) benchmark(wrapper)
@pytest.mark.base
@pytest.mark.parametrize("node_type", node_types) @pytest.mark.parametrize("node_type", node_types)
@pytest.mark.parametrize("quad_type", quad_types) @pytest.mark.parametrize("quad_type", quad_types)
def test_canintegratepolynomials(node_type, quad_type): def test_canintegratepolynomials(node_type, quad_type):
...@@ -61,6 +62,7 @@ def test_canintegratepolynomials(node_type, quad_type): ...@@ -61,6 +62,7 @@ def test_canintegratepolynomials(node_type, quad_type):
) )
@pytest.mark.base
@pytest.mark.parametrize("node_type", node_types) @pytest.mark.parametrize("node_type", node_types)
@pytest.mark.parametrize("quad_type", quad_types) @pytest.mark.parametrize("quad_type", quad_types)
def test_relateQandSmat(node_type, quad_type): def test_relateQandSmat(node_type, quad_type):
...@@ -82,6 +84,7 @@ def test_relateQandSmat(node_type, quad_type): ...@@ -82,6 +84,7 @@ def test_relateQandSmat(node_type, quad_type):
) )
@pytest.mark.base
@pytest.mark.parametrize("node_type", node_types) @pytest.mark.parametrize("node_type", node_types)
@pytest.mark.parametrize("quad_type", quad_types) @pytest.mark.parametrize("quad_type", quad_types)
def test_partialquadraturewithQ(node_type, quad_type): def test_partialquadraturewithQ(node_type, quad_type):
...@@ -104,6 +107,7 @@ def test_partialquadraturewithQ(node_type, quad_type): ...@@ -104,6 +107,7 @@ def test_partialquadraturewithQ(node_type, quad_type):
) )
@pytest.mark.base
@pytest.mark.parametrize("node_type", node_types) @pytest.mark.parametrize("node_type", node_types)
@pytest.mark.parametrize("quad_type", quad_types) @pytest.mark.parametrize("quad_type", quad_types)
def test_partialquadraturewithS(node_type, quad_type): def test_partialquadraturewithS(node_type, quad_type):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment