diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f9e7fd7..03c1e68 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @mdolab/niceplots_maintainers \ No newline at end of file +* @mdolab/niceplots_maintainers diff --git a/.github/workflows/niceplots.yml b/.github/workflows/niceplots.yml index 083ae68..4beea36 100644 --- a/.github/workflows/niceplots.yml +++ b/.github/workflows/niceplots.yml @@ -10,11 +10,8 @@ on: pull_request: jobs: - black: - uses: mdolab/.github/.github/workflows/black.yaml@main - - flake8: - uses: mdolab/.github/.github/workflows/flake8.yaml@main + format-and-lint: + uses: mdolab/.github/.github/workflows/format-and-lint.yaml@main test: runs-on: ubuntu-latest @@ -68,6 +65,6 @@ jobs: # --- publish to PyPI pypi: - needs: [test, flake8, black] + needs: [test, format-and-lint] uses: mdolab/.github/.github/workflows/pypi.yaml@main secrets: inherit diff --git a/.gitignore b/.gitignore index 2bed3e9..c774172 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.pre-commit-config.yaml +ruff.toml + # Ignore any figures, except the reference images used for testing *.pdf *.png diff --git a/examples/testExamples.sh b/examples/testExamples.sh index a08ffa1..f8fb849 100755 --- a/examples/testExamples.sh +++ b/examples/testExamples.sh @@ -5,4 +5,4 @@ for f in *.py do echo "Testing $f" python "$f" -done \ No newline at end of file +done diff --git a/niceplots/fonts/OFL.txt b/niceplots/fonts/OFL.txt index a0ca110..d9e8634 100644 --- a/niceplots/fonts/OFL.txt +++ b/niceplots/fonts/OFL.txt @@ -18,7 +18,7 @@ with others. The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, +fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The diff --git a/niceplots/fonts/SIL Open Font License.txt b/niceplots/fonts/SIL Open Font License.txt index 8ed8440..daf9c18 100644 --- a/niceplots/fonts/SIL Open Font License.txt +++ b/niceplots/fonts/SIL Open Font License.txt @@ -1,15 +1,15 @@ -Copyright (C) Authors of original metafont fonts: -Donald Ervin Knuth (cm, concrete fonts) -1995, 1996, 1997 J"org Knappen, 1990, 1992 Norbert Schwarz (ec fonts) -1992-2006 A.Khodulev, O.Lapko, A.Berdnikov, V.Volovich (lh fonts) -1997-2005 Claudio Beccari (cb greek fonts) -2002 FUKUI Rei (tipa fonts) -2003-2005 Han The Thanh (Vietnamese fonts) -1996-2005 Walter Schmidt (cmbright fonts) - -Copyright (C) 2003-2009, Andrey V. Panov (panov@canopus.iacp.dvo.ru), -with Reserved Font Family Name "Computer Modern Unicode fonts". - +Copyright (C) Authors of original metafont fonts: +Donald Ervin Knuth (cm, concrete fonts) +1995, 1996, 1997 J"org Knappen, 1990, 1992 Norbert Schwarz (ec fonts) +1992-2006 A.Khodulev, O.Lapko, A.Berdnikov, V.Volovich (lh fonts) +1997-2005 Claudio Beccari (cb greek fonts) +2002 FUKUI Rei (tipa fonts) +2003-2005 Han The Thanh (Vietnamese fonts) +1996-2005 Walter Schmidt (cmbright fonts) + +Copyright (C) 2003-2009, Andrey V. Panov (panov@canopus.iacp.dvo.ru), +with Reserved Font Family Name "Computer Modern Unicode fonts". + This Font Software is licensed under the SIL Open Font License, Version 1.1. @@ -52,4 +52,4 @@ TERMINATION This license becomes null and void if any of the above conditions are not met. DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/niceplots/utils.py b/niceplots/utils.py index bdda15c..b298b52 100644 --- a/niceplots/utils.py +++ b/niceplots/utils.py @@ -180,7 +180,8 @@ def handle_close(evt): def adjust_spines(ax=None, spines=["left", "bottom"], outward=True): """Function to shift the axes/spines so they have that offset - Doumont look.""" + Doumont look. + """ if ax is None: ax = plt.gca() @@ -412,7 +413,7 @@ def horiz_bar(labels, times, header, nd=1, size=[5, 0.5], color=None): t_max_digits = tm # Actual loop that draws each bar - for j, (l, t, ax) in enumerate(zip(labels, times, axes)): + for j, (label, t, ax) in enumerate(zip(labels, times, axes)): # Draw the gray line and singular yellow dot ax.axhline(y=1, c=line_color, lw=3, zorder=0, alpha=0.5) ax.scatter([t], [1], c=color, lw=0, s=100, zorder=1, clip_on=False) @@ -435,7 +436,7 @@ def horiz_bar(labels, times, header, nd=1, size=[5, 0.5], color=None): ax.spines["left"].set_visible(False) ax.spines["right"].set_visible(False) ax.spines["bottom"].set_visible(False) - ax.set_ylabel(l, rotation="horizontal", ha="right", va="center") + ax.set_ylabel(label, rotation="horizontal", ha="right", va="center") string = "{number:.{digits}f}".format(number=t, digits=nd) ax.annotate( string, @@ -482,7 +483,7 @@ def stacked_plots( f, axarr = plt.subplots(n, figsize=figsize) for i, (ylabel, ydata) in enumerate(data_dict.items()): - if type(ydata) == dict: + if isinstance(ydata, dict): if "limits" in ydata.keys(): axarr[i].set_ylim(ydata["limits"]) elif "ticks" in ydata.keys(): @@ -497,7 +498,7 @@ def stacked_plots( # Doesn't correctly work when we give a dict version if xlim is not None: - if type(ydata) == dict: + if isinstance(ydata, dict): ydata = ydata["data"] ydata = np.array(ydata, dtype="float") no_nan_y = ydata[np.isfinite(ydata)] @@ -506,7 +507,7 @@ def stacked_plots( for j, data_dict in enumerate(data_dict_list): for i, (_, ydata) in enumerate(data_dict.items()): - if type(ydata) == dict: + if isinstance(ydata, dict): ydata = ydata["data"] axarr[i].plot(xdata, ydata, clip_on=False, lw=6 * line_scaler, color=colors[j]) if not lines_only: @@ -624,9 +625,7 @@ def plot_opt_prob( # --- Check if user has a recent enough version of matplotlib to use hashed boundaries --- if conStyle.lower() == "hashed": - try: - patheffects.withTickedStroke - except AttributeError: + if not hasattr(patheffects, "withTickedStroke"): warnings.warn( "matplotlib >= 3.4 is required for hashed inequality constrain boundaries, switching to shaded inequality constraint style", stacklevel=2,