From 1cbb320c34c77d371060c63f4dd498c0a6f67a49 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 26 Oct 2023 09:41:59 -0400 Subject: [PATCH 1/3] chore: move to Ruff formatter Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 9 +++------ README.md | 3 --- docs/index.rst | 4 +--- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 675b8492..f34798e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,16 +3,11 @@ ci: autofix_commit_msg: "style: pre-commit fixes" repos: - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.11.0 - hooks: - - id: black-jupyter - - repo: https://github.com/adamchainz/blacken-docs rev: "1.16.0" hooks: - id: blacken-docs - additional_dependencies: [black==23.11.0] + additional_dependencies: [black==23.*] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 @@ -56,6 +51,8 @@ repos: hooks: - id: ruff args: ["--fix", "--show-fixes"] + - id: ruff-format + types_or: [python, pyi, jupyter] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.7.0 diff --git a/README.md b/README.md index 32097096..e0502dd3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Actions Status][actions-badge]][actions-link] [![Documentation Status][rtd-badge]][rtd-link] -[![Code style: black][black-badge]][black-link] [![PyPI version][pypi-version]][pypi-link] [![Conda-Forge][conda-badge]][conda-link] @@ -290,8 +289,6 @@ Support for this work was provided by the National Science Foundation cooperativ [actions-badge]: https://github.com/scikit-hep/boost-histogram/workflows/Tests/badge.svg [actions-link]: https://github.com/scikit-hep/boost-histogram/actions -[black-badge]: https://img.shields.io/badge/code%20style-black-000000.svg -[black-link]: https://github.com/psf/black [conda-badge]: https://img.shields.io/conda/vn/conda-forge/boost-histogram [conda-link]: https://github.com/conda-forge/boost-histogram-feedstock [github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github diff --git a/docs/index.rst b/docs/index.rst index d848655c..d947b98e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,7 @@ Welcome to boost-histogram's documentation! =========================================== -|Actions Status| |Documentation Status| |Code style: black| |PyPI version| |Conda-Forge| +|Actions Status| |Documentation Status| |PyPI version| |Conda-Forge| |PyPI platforms| |DOI| |GitHub Discussion| |Gitter| |Scikit-HEP| Boost-histogram (`source `__) is @@ -116,8 +116,6 @@ Indices and tables :target: https://github.com/scikit-hep/boost-histogram/actions .. |Documentation Status| image:: https://readthedocs.org/projects/boost-histogram/badge/?version=latest :target: https://boost-histogram.readthedocs.io/en/latest/?badge=latest -.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/ambv/black .. |PyPI version| image:: https://badge.fury.io/py/boost-histogram.svg :target: https://pypi.org/project/boost-histogram .. |Conda-Forge| image:: https://img.shields.io/conda/vn/conda-forge/boost-histogram From bfad20f0b47a04cdc11b4de45c1f0aecb07649e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:45:22 +0000 Subject: [PATCH 2/3] style: pre-commit fixes --- notebooks/BoostHistogramHandsOn.ipynb | 30 +++++++++++++-------------- notebooks/aghast.ipynb | 2 +- notebooks/xarray.ipynb | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/notebooks/BoostHistogramHandsOn.ipynb b/notebooks/BoostHistogramHandsOn.ipynb index 38f57ea2..4096c1e4 100644 --- a/notebooks/BoostHistogramHandsOn.ipynb +++ b/notebooks/BoostHistogramHandsOn.ipynb @@ -169,7 +169,7 @@ } ], "source": [ - "plt.bar(hist1.axes[0].centers, hist1.values(), width=hist1.axes[0].widths);" + "plt.bar(hist1.axes[0].centers, hist1.values(), width=hist1.axes[0].widths)" ] }, { @@ -192,7 +192,7 @@ "metadata": {}, "outputs": [], "source": [ - "plothist = lambda h: plt.bar(*h.axes.centers, h.values(), width=h.axes.widths[0]);" + "plothist = lambda h: plt.bar(*h.axes.centers, h.values(), width=h.axes.widths[0])" ] }, { @@ -225,7 +225,7 @@ } ], "source": [ - "plt.step(hist1.axes[0].edges[:-1], hist1.values(), where=\"post\");" + "plt.step(hist1.axes[0].edges[:-1], hist1.values(), where=\"post\")" ] }, { @@ -258,7 +258,7 @@ } ], "source": [ - "plt.stairs(hist1.values(), hist1.axes[0].edges);" + "plt.stairs(hist1.values(), hist1.axes[0].edges)" ] }, { @@ -368,7 +368,7 @@ ], "source": [ "hist2 = bh.numpy.histogram(data1, bins=\"auto\", histogram=bh.Histogram)\n", - "plothist(hist2);" + "plothist(hist2)" ] }, { @@ -523,7 +523,7 @@ } ], "source": [ - "plothist2d(hist3);" + "plothist2d(hist3)" ] }, { @@ -595,7 +595,7 @@ } ], "source": [ - "plothist2d(hist3d.project(0, 1));" + "plothist2d(hist3d.project(0, 1))" ] }, { @@ -630,7 +630,7 @@ } ], "source": [ - "plothist2d(hist3);" + "plothist2d(hist3)" ] }, { @@ -663,7 +663,7 @@ } ], "source": [ - "plothist2d(hist3[:, bh.loc(0.25) : bh.loc(0.75)]);" + "plothist2d(hist3[:, bh.loc(0.25) : bh.loc(0.75)])" ] }, { @@ -763,7 +763,7 @@ ], "source": [ "plothist(hist3[:, :: bh.sum])\n", - "plothist(hist3[:: bh.sum, :]);" + "plothist(hist3[:: bh.sum, :])" ] }, { @@ -796,7 +796,7 @@ } ], "source": [ - "plothist2d(hist3[: 50 : bh.rebin(2), 50 :: bh.rebin(2)]);" + "plothist2d(hist3[: 50 : bh.rebin(2), 50 :: bh.rebin(2)])" ] }, { @@ -1065,7 +1065,7 @@ " 10,\n", "]\n", "d7, e7 = np.histogram(data1 - 3.5, bins=bins, density=True)\n", - "plt.hist(data1 - 3.5, bins=bins, density=True);" + "plt.hist(data1 - 3.5, bins=bins, density=True)" ] }, { @@ -1143,7 +1143,7 @@ } ], "source": [ - "plt.bar(hist7.axes[0].centers, view, width=hist7.axes[0].widths);" + "plt.bar(hist7.axes[0].centers, view, width=hist7.axes[0].widths)" ] }, { @@ -1214,7 +1214,7 @@ } ], "source": [ - "plothist2d(hist8);" + "plothist2d(hist8)" ] }, { @@ -1276,7 +1276,7 @@ ], "source": [ "ax = plt.subplot(111, polar=True)\n", - "plothist(hist9);" + "plothist(hist9)" ] } ], diff --git a/notebooks/aghast.ipynb b/notebooks/aghast.ipynb index 0fc22433..400dab81 100644 --- a/notebooks/aghast.ipynb +++ b/notebooks/aghast.ipynb @@ -128,7 +128,7 @@ ], "source": [ "h = bh.Histogram(uproot_hist)\n", - "plt.bar(h.axes[0].centers, h.values(), width=h.axes[0].widths);" + "plt.bar(h.axes[0].centers, h.values(), width=h.axes[0].widths)" ] }, { diff --git a/notebooks/xarray.ipynb b/notebooks/xarray.ipynb index 41fe6886..5c96ff10 100644 --- a/notebooks/xarray.ipynb +++ b/notebooks/xarray.ipynb @@ -145,7 +145,7 @@ "source": [ "bh_bins = bh.axis.Regular(19, -4, 4)\n", "bh_hist = bh.Histogram(bh_bins).fill(np.asarray(da).flatten())\n", - "plt.plot(bh_hist.axes[0].centers, bh_hist.values());" + "plt.plot(bh_hist.axes[0].centers, bh_hist.values())" ] }, { @@ -224,7 +224,7 @@ "source": [ "h = bh_xhistogram(da, bins=[bins])\n", "display(h)\n", - "h.plot();" + "h.plot()" ] }, { From 516141241d869255da9060e1e5b002ddd07f5338 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Nov 2023 14:19:42 -0500 Subject: [PATCH 3/3] chore: update to working version of ruff-formatter Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 4 ++-- notebooks/BoostHistogramHandsOn.ipynb | 30 +++++++++++++-------------- notebooks/aghast.ipynb | 2 +- notebooks/xarray.ipynb | 4 ++-- pyproject.toml | 3 ++- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f34798e1..dd0c88b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,7 +47,7 @@ repos: ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.5" + rev: "v0.1.6" hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -83,7 +83,7 @@ repos: exclude: .pre-commit-config.yaml - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v17.0.4 + rev: v17.0.5 hooks: - id: clang-format types_or: [c++] diff --git a/notebooks/BoostHistogramHandsOn.ipynb b/notebooks/BoostHistogramHandsOn.ipynb index 4096c1e4..38f57ea2 100644 --- a/notebooks/BoostHistogramHandsOn.ipynb +++ b/notebooks/BoostHistogramHandsOn.ipynb @@ -169,7 +169,7 @@ } ], "source": [ - "plt.bar(hist1.axes[0].centers, hist1.values(), width=hist1.axes[0].widths)" + "plt.bar(hist1.axes[0].centers, hist1.values(), width=hist1.axes[0].widths);" ] }, { @@ -192,7 +192,7 @@ "metadata": {}, "outputs": [], "source": [ - "plothist = lambda h: plt.bar(*h.axes.centers, h.values(), width=h.axes.widths[0])" + "plothist = lambda h: plt.bar(*h.axes.centers, h.values(), width=h.axes.widths[0]);" ] }, { @@ -225,7 +225,7 @@ } ], "source": [ - "plt.step(hist1.axes[0].edges[:-1], hist1.values(), where=\"post\")" + "plt.step(hist1.axes[0].edges[:-1], hist1.values(), where=\"post\");" ] }, { @@ -258,7 +258,7 @@ } ], "source": [ - "plt.stairs(hist1.values(), hist1.axes[0].edges)" + "plt.stairs(hist1.values(), hist1.axes[0].edges);" ] }, { @@ -368,7 +368,7 @@ ], "source": [ "hist2 = bh.numpy.histogram(data1, bins=\"auto\", histogram=bh.Histogram)\n", - "plothist(hist2)" + "plothist(hist2);" ] }, { @@ -523,7 +523,7 @@ } ], "source": [ - "plothist2d(hist3)" + "plothist2d(hist3);" ] }, { @@ -595,7 +595,7 @@ } ], "source": [ - "plothist2d(hist3d.project(0, 1))" + "plothist2d(hist3d.project(0, 1));" ] }, { @@ -630,7 +630,7 @@ } ], "source": [ - "plothist2d(hist3)" + "plothist2d(hist3);" ] }, { @@ -663,7 +663,7 @@ } ], "source": [ - "plothist2d(hist3[:, bh.loc(0.25) : bh.loc(0.75)])" + "plothist2d(hist3[:, bh.loc(0.25) : bh.loc(0.75)]);" ] }, { @@ -763,7 +763,7 @@ ], "source": [ "plothist(hist3[:, :: bh.sum])\n", - "plothist(hist3[:: bh.sum, :])" + "plothist(hist3[:: bh.sum, :]);" ] }, { @@ -796,7 +796,7 @@ } ], "source": [ - "plothist2d(hist3[: 50 : bh.rebin(2), 50 :: bh.rebin(2)])" + "plothist2d(hist3[: 50 : bh.rebin(2), 50 :: bh.rebin(2)]);" ] }, { @@ -1065,7 +1065,7 @@ " 10,\n", "]\n", "d7, e7 = np.histogram(data1 - 3.5, bins=bins, density=True)\n", - "plt.hist(data1 - 3.5, bins=bins, density=True)" + "plt.hist(data1 - 3.5, bins=bins, density=True);" ] }, { @@ -1143,7 +1143,7 @@ } ], "source": [ - "plt.bar(hist7.axes[0].centers, view, width=hist7.axes[0].widths)" + "plt.bar(hist7.axes[0].centers, view, width=hist7.axes[0].widths);" ] }, { @@ -1214,7 +1214,7 @@ } ], "source": [ - "plothist2d(hist8)" + "plothist2d(hist8);" ] }, { @@ -1276,7 +1276,7 @@ ], "source": [ "ax = plt.subplot(111, polar=True)\n", - "plothist(hist9)" + "plothist(hist9);" ] } ], diff --git a/notebooks/aghast.ipynb b/notebooks/aghast.ipynb index 400dab81..0fc22433 100644 --- a/notebooks/aghast.ipynb +++ b/notebooks/aghast.ipynb @@ -128,7 +128,7 @@ ], "source": [ "h = bh.Histogram(uproot_hist)\n", - "plt.bar(h.axes[0].centers, h.values(), width=h.axes[0].widths)" + "plt.bar(h.axes[0].centers, h.values(), width=h.axes[0].widths);" ] }, { diff --git a/notebooks/xarray.ipynb b/notebooks/xarray.ipynb index 5c96ff10..41fe6886 100644 --- a/notebooks/xarray.ipynb +++ b/notebooks/xarray.ipynb @@ -145,7 +145,7 @@ "source": [ "bh_bins = bh.axis.Regular(19, -4, 4)\n", "bh_hist = bh.Histogram(bh_bins).fill(np.asarray(da).flatten())\n", - "plt.plot(bh_hist.axes[0].centers, bh_hist.values())" + "plt.plot(bh_hist.axes[0].centers, bh_hist.values());" ] }, { @@ -224,7 +224,7 @@ "source": [ "h = bh_xhistogram(da, bins=[bins])\n", "display(h)\n", - "h.plot()" + "h.plot();" ] }, { diff --git a/pyproject.toml b/pyproject.toml index 34bc9ed1..b549b2aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,7 +148,8 @@ extend-select = [ ignore = [ "PLR", # Design related pylint codes "E501", # Line too long - "PT011", "PT013" + "PT011", "PT013", # Incorrect pytest codes + "ISC001", # Conflicts with the formatter ] unfixable = [ "T20", # Removes print statements