From 52ca8db061e8574a910aba7f9b2dcfdcc01d65f3 Mon Sep 17 00:00:00 2001 From: Felix Fischer <f.fischer@ifas.rwth-aachen.de> Date: Mon, 29 Jan 2024 12:15:37 +0100 Subject: [PATCH] Add import of scienceplots --- src/scientific_plots/__init__.py | 2 +- src/scientific_plots/default_plots.py | 10 ++++++---- src/scientific_plots/plot_settings.py | 2 ++ src/scientific_plots/utilities.py | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scientific_plots/__init__.py b/src/scientific_plots/__init__.py index 0d1ba1d..76e0535 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.1" +__version__ = "1.8.2" diff --git a/src/scientific_plots/default_plots.py b/src/scientific_plots/default_plots.py index 17c4d22..00b76b1 100644 --- a/src/scientific_plots/default_plots.py +++ b/src/scientific_plots/default_plots.py @@ -24,6 +24,7 @@ mpl.use("Agg") In = TypeVar("In", List[float], Tuple[float], Vector) +# pylint: disable=invalid-name In2D = TypeVar("In2D", List[List[float]], List[Vector], Tuple[Vector], Matrix) @@ -239,6 +240,7 @@ def plot_surface(X: In2D, Y: In2D, Z: In2D, antialiased: bool = True, rcount: int = 200, ccount: int = 200) -> None: """create a 2D surface plot of meshgrid-like valued Xs, Ys and Zs""" + # pylint: disable=too-many-branches if not check_inputs( np.array(X).flatten(), np.array(Z).flatten(), xlabel, zlabel): @@ -409,8 +411,8 @@ def two_plots(x1: In, y1: In, label1: str, if xlim is not None: pass elif outer: - xlim = (min(min(x1), min(x2)), - max(max(x1), max(x2))) + xlim = (min(*x1, *x2), + max(*x1, *x2)) else: xlim = (max(min(x1), min(x2)), min(max(x1), max(x2))) @@ -473,8 +475,8 @@ def three_plots(x1: In, y1: In, label1: str, plt.plot(x3, y3, label=label3, linestyle="dotted") plt.xlabel(xlabel) plt.ylabel(ylabel) - min_ = min(min(y1), min(y2), min(y3)) - max_ = max(max(y1), max(y2), max(y3)) + min_ = min(*y1, *y2, *y3) + max_ = max(*y1, *y2, *y3) if not logscale: plt.ylim( min_ - (max_ - min_) * 0.02, diff --git a/src/scientific_plots/plot_settings.py b/src/scientific_plots/plot_settings.py index 95eca75..ed49b62 100644 --- a/src/scientific_plots/plot_settings.py +++ b/src/scientific_plots/plot_settings.py @@ -18,6 +18,8 @@ from pathlib import Path from warnings import warn, catch_warnings, simplefilter from textwrap import dedent +# pylint: disable=unused-import +import scienceplots # noqa: F401 import mpl_toolkits import matplotlib as mpl import matplotlib.pyplot as plt diff --git a/src/scientific_plots/utilities.py b/src/scientific_plots/utilities.py index 512d61f..af8c645 100644 --- a/src/scientific_plots/utilities.py +++ b/src/scientific_plots/utilities.py @@ -145,7 +145,7 @@ def write_file(filename: Union[Path, str], """write the rows given in 'arga' to a file""" # write data to a file if not any(args[0]): - raise Exception("Tried to write an empty row to a file") + raise ValueError("Tried to write an empty row to a file.") if isinstance(filename, str): filename = Path(filename) with open(filename, "w", encoding="utf-8") as output_file: -- GitLab