From 6a765b183bbe6b41d15b759606f130ff603d5070 Mon Sep 17 00:00:00 2001 From: Felix Fischer <f.fischer@ifas.rwth-aachen.de> Date: Wed, 30 Apr 2025 13:50:01 +0200 Subject: [PATCH] don't translate bar --- src/scientific_plots/__init__.py | 2 +- src/scientific_plots/utilities.py | 5 +++-- tests/test_plot_manual.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/scientific_plots/__init__.py b/src/scientific_plots/__init__.py index 8536ab9..a198636 100644 --- a/src/scientific_plots/__init__.py +++ b/src/scientific_plots/__init__.py @@ -5,4 +5,4 @@ useful across several different projects and repositories. It also contains stub-files with several data-type annotations for scipy and matplot-lib functions.""" -__version__ = "1.8.11" +__version__ = "1.8.12" diff --git a/src/scientific_plots/utilities.py b/src/scientific_plots/utilities.py index a0b6428..ee48262 100644 --- a/src/scientific_plots/utilities.py +++ b/src/scientific_plots/utilities.py @@ -207,7 +207,7 @@ def translate(string: str, reverse: bool = False) -> str: @input reverse translate ger->en if set to true @return the german translation of the same string""" - if r"$" in string or not string: + if r"$" in string or not string or len(string) <= 1: return string if reverse: @@ -267,7 +267,8 @@ def translate(string: str, reverse: bool = False) -> str: "plot": "Graph", "orifice": "Blende", "Hagen–Poiseuille": "Hagen-Poiseuille", - "test": "Test" + "test": "Test", + "bar": "bar" }) if not reverse and r"\times" not in string: for key, value in _dict.items(): diff --git a/tests/test_plot_manual.py b/tests/test_plot_manual.py index c8a5cf2..45b76f9 100644 --- a/tests/test_plot_manual.py +++ b/tests/test_plot_manual.py @@ -31,7 +31,7 @@ def test_two_plots() -> None: filename.parent.mkdir(exist_ok=True) two_plots(x_test, y_test1, "plot1", x_test, y_test2, "plot2", - "distance", r"$\dot{m} = \frac{a}{b}$ leakage [bar]", + "$p$ distance [m]", r"$\dot{m} = \frac{a}{b}$ leakage [bar]", filename) assert filename.exists() @@ -95,7 +95,7 @@ def test_fallback() -> None: def simple_plot() -> None: """Create a simple plot.""" plt.plot(x_test, y_test, label="test") - plt.xlabel("$x$ [m]") + plt.xlabel("$p$ [bar]") plt.ylabel(r"$\sqrt{y_c}$ [1/m]") plt.legend() plt.gca().set_yscale("log") -- GitLab