From 9f07f80b1e4fb215a72dcec9a7ab6f30b9251475 Mon Sep 17 00:00:00 2001 From: Alexander Held Date: Sun, 2 Feb 2025 19:46:10 +0100 Subject: [PATCH 1/3] update to black 2025 style --- src/cabinetry/tabulate.py | 8 ++--- tests/test_tabulate.py | 62 +++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/cabinetry/tabulate.py b/src/cabinetry/tabulate.py index b58d7afd..686a06e6 100644 --- a/src/cabinetry/tabulate.py +++ b/src/cabinetry/tabulate.py @@ -121,7 +121,7 @@ def _yields_per_bin( _header_name( channel_name, i_bin ): f"{model_yields[i_chan][i_sam][i_bin]:.2f} " - f"\u00B1 {total_stdev_model[i_chan][i_sam][i_bin]:.2f}" + f"\u00b1 {total_stdev_model[i_chan][i_sam][i_bin]:.2f}" } ) table.append(sample_dict) @@ -140,7 +140,7 @@ def _yields_per_bin( { header_name: ( f"{total_model[i_bin]:.2f} " - f"\u00B1 {total_stdev_model[i_chan][-1][i_bin]:.2f}" + f"\u00b1 {total_stdev_model[i_chan][-1][i_bin]:.2f}" ) } ) @@ -188,7 +188,7 @@ def _yields_per_channel( sample_dict.update( { channel_name: f"{model_yields[i_chan][i_sam]:.2f} " - f"\u00B1 {total_stdev_model[i_chan][i_sam]:.2f}" + f"\u00b1 {total_stdev_model[i_chan][i_sam]:.2f}" } ) table.append(sample_dict) @@ -201,7 +201,7 @@ def _yields_per_channel( total_dict.update( { channel_name: f"{total_model:.2f} " - f"\u00B1 {total_stdev_model[i_chan][-1]:.2f}" + f"\u00b1 {total_stdev_model[i_chan][-1]:.2f}" } ) data_dict.update({channel_name: f"{data[i_chan]:.2f}"}) diff --git a/tests/test_tabulate.py b/tests/test_tabulate.py index 5c7e82ac..bcabd753 100644 --- a/tests/test_tabulate.py +++ b/tests/test_tabulate.py @@ -34,15 +34,15 @@ def test__yields_per_bin(example_spec_multibin, example_spec_with_background, ca assert yield_table == [ { "sample": "Signal", - "region_1\nbin 1": "25.00 \u00B1 5.00", - "region_1\nbin 2": "5.00 \u00B1 2.00", - "region_2\nbin 1": "8.00 \u00B1 1.00", + "region_1\nbin 1": "25.00 \u00b1 5.00", + "region_1\nbin 2": "5.00 \u00b1 2.00", + "region_2\nbin 1": "8.00 \u00b1 1.00", }, { "sample": "total", - "region_1\nbin 1": "25.00 \u00B1 5.00", - "region_1\nbin 2": "5.00 \u00B1 2.00", - "region_2\nbin 1": "8.00 \u00B1 1.00", + "region_1\nbin 1": "25.00 \u00b1 5.00", + "region_1\nbin 2": "5.00 \u00b1 2.00", + "region_2\nbin 1": "8.00 \u00b1 1.00", }, { "sample": "data", @@ -65,9 +65,9 @@ def test__yields_per_bin(example_spec_multibin, example_spec_with_background, ca model, yields, total_stdev, data, channels, label ) assert yield_table == [ - {"sample": "Background", "Signal Region\nbin 1": "150.00 \u00B1 6.45"}, - {"sample": "Signal", "Signal Region\nbin 1": "50.00 \u00B1 2.15"}, - {"sample": "total", "Signal Region\nbin 1": "200.00 \u00B1 8.60"}, + {"sample": "Background", "Signal Region\nbin 1": "150.00 \u00b1 6.45"}, + {"sample": "Signal", "Signal Region\nbin 1": "50.00 \u00b1 2.15"}, + {"sample": "total", "Signal Region\nbin 1": "200.00 \u00b1 8.60"}, {"sample": "data", "Signal Region\nbin 1": "160.00"}, ] @@ -77,18 +77,18 @@ def test__save_tables(tmp_path): "yields_per_bin": [ { "sample": "Background", - "Signal_region\nbin 1": "111.00 \u00B1 9.50", - "Signal_region\nbin 2": "116.00 \u00B1 10.00", + "Signal_region\nbin 1": "111.00 \u00b1 9.50", + "Signal_region\nbin 2": "116.00 \u00b1 10.00", }, { "sample": "Signal", - "Signal_region\nbin 1": "1.00 \u00B1 0.50", - "Signal_region\nbin 2": "5.00 \u00B1 1.00", + "Signal_region\nbin 1": "1.00 \u00b1 0.50", + "Signal_region\nbin 2": "5.00 \u00b1 1.00", }, { "sample": "total", - "Signal_region\nbin 1": "112.00 \u00B1 10.00", - "Signal_region\nbin 2": "121.00 \u00B1 11.00", + "Signal_region\nbin 1": "112.00 \u00b1 10.00", + "Signal_region\nbin 2": "121.00 \u00b1 11.00", }, { "sample": "data", @@ -97,9 +97,9 @@ def test__save_tables(tmp_path): }, ], "yields_per_channel": [ - {"sample": "Background", "Signal_region": "227.00 \u00B1 16.00"}, - {"sample": "Signal", "Signal_region": "6.00 \u00B1 1.00"}, - {"sample": "total", "Signal_region": "233.00 \u00B1 17.00"}, + {"sample": "Background", "Signal_region": "227.00 \u00b1 16.00"}, + {"sample": "Signal", "Signal_region": "6.00 \u00b1 1.00"}, + {"sample": "total", "Signal_region": "233.00 \u00b1 17.00"}, {"sample": "data", "Signal_region": "235.00"}, ], } @@ -113,17 +113,17 @@ def test__save_tables(tmp_path): "sample Signal_region Signal_region\n" " bin 1 bin 2\n" "---------- --------------- ---------------\n" - "Background 111.00 \u00B1 9.50 116.00 \u00B1 10.00\n" - "Signal 1.00 \u00B1 0.50 5.00 \u00B1 1.00\n" - "total 112.00 \u00B1 10.00 121.00 \u00B1 11.00\n" + "Background 111.00 \u00b1 9.50 116.00 \u00b1 10.00\n" + "Signal 1.00 \u00b1 0.50 5.00 \u00b1 1.00\n" + "total 112.00 \u00b1 10.00 121.00 \u00b1 11.00\n" "data 112.00 123.00\n" ) assert fname_channel.read_text() == ( "sample Signal_region\n" "---------- ---------------\n" - "Background 227.00 \u00B1 16.00\n" - "Signal 6.00 \u00B1 1.00\n" - "total 233.00 \u00B1 17.00\n" + "Background 227.00 \u00b1 16.00\n" + "Signal 6.00 \u00b1 1.00\n" + "total 233.00 \u00b1 17.00\n" "data 235.00\n" ) @@ -159,13 +159,13 @@ def test__yields_per_channel( assert yield_table == [ { "sample": "Signal", - "region_1": "30.00 \u00B1 5.39", - "region_2": "8.00 \u00B1 1.00", + "region_1": "30.00 \u00b1 5.39", + "region_2": "8.00 \u00b1 1.00", }, { "sample": "total", - "region_1": "30.00 \u00B1 5.39", - "region_2": "8.00 \u00B1 1.00", + "region_1": "30.00 \u00b1 5.39", + "region_2": "8.00 \u00b1 1.00", }, {"sample": "data", "region_1": "43.00", "region_2": "10.00"}, ] @@ -185,9 +185,9 @@ def test__yields_per_channel( model, yields, total_stdev, data, channels, label ) assert yield_table == [ - {"sample": "Background", "Signal Region": "150.00 \u00B1 6.45"}, - {"sample": "Signal", "Signal Region": "50.00 \u00B1 2.15"}, - {"sample": "total", "Signal Region": "200.00 \u00B1 8.60"}, + {"sample": "Background", "Signal Region": "150.00 \u00b1 6.45"}, + {"sample": "Signal", "Signal Region": "50.00 \u00b1 2.15"}, + {"sample": "total", "Signal Region": "200.00 \u00b1 8.60"}, {"sample": "data", "Signal Region": "160.00"}, ] From 96122b4b825e711fa96df0c46da4e246b76b3ab8 Mon Sep 17 00:00:00 2001 From: Alexander Held Date: Sun, 2 Feb 2025 19:49:05 +0100 Subject: [PATCH 2/3] update pre-commit --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 720710b5..722972e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ repos: - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.8.0 + rev: 25.1.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.14.1 hooks: - id: mypy name: mypy with Python 3.12 @@ -17,12 +17,12 @@ repos: - id: flake8 additional_dependencies: [flake8-bugbear, flake8-import-order, flake8-print] - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.1 hooks: - id: pyupgrade args: ["--py38-plus"] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files args: ["--maxkb=100"] @@ -34,7 +34,7 @@ repos: # configuration duplicated in setup.cfg args: ["--match=(?!setup|example).*\\.py'", "--match-dir='^(?!(tests|utils|docs)).*'", "--convention=google"] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell args: ["-L", "hist", "src", "tests", "utils", "docs/*rst"] From cb4ade99a1d31379f691e50506251a4bcd520ff5 Mon Sep 17 00:00:00 2001 From: Alexander Held Date: Sun, 2 Feb 2025 20:00:13 +0100 Subject: [PATCH 3/3] skip mypy --- .pre-commit-config.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 722972e1..b1d18e88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,14 @@ repos: rev: 25.1.0 hooks: - id: black -- repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.14.1 - hooks: - - id: mypy - name: mypy with Python 3.12 - files: src/cabinetry - additional_dependencies: ["numpy>=1.22", "boost-histogram>=1.0.1", "click>=8", "types-tabulate", "types-PyYAML", "hist>=2.3.0"] - args: ["--python-version=3.12"] +# - repo: https://github.com/pre-commit/mirrors-mypy +# rev: v1.14.1 +# hooks: +# - id: mypy +# name: mypy with Python 3.12 +# files: src/cabinetry +# additional_dependencies: ["numpy>=1.22", "boost-histogram>=1.0.1", "click>=8", "types-tabulate", "types-PyYAML", "hist>=2.3.0"] +# args: ["--python-version=3.12"] - repo: https://github.com/pycqa/flake8 rev: 7.1.1 hooks: