plothist 1.6.0__tar.gz → 1.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plothist-1.6.0 → plothist-1.7.0}/.github/workflows/cd.yaml +3 -3
- {plothist-1.6.0 → plothist-1.7.0}/.github/workflows/ci.yaml +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/.github/workflows/coverage.yaml +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/.github/workflows/pr.yaml +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/.pre-commit-config.yaml +7 -7
- plothist-1.7.0/AUTHORS.md +2 -0
- plothist-1.7.0/CONTRIBUTING.md +1 -0
- {plothist-1.6.0 → plothist-1.7.0}/PKG-INFO +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/docs/basics/variable_registry.rst +17 -19
- plothist-1.7.0/docs/img/2d_hist_correlations_0.png +0 -0
- plothist-1.7.0/docs/img/2d_hist_correlations_1.png +0 -0
- plothist-1.7.0/docs/img/2d_hist_correlations_2.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/usage/installation.rst +2 -2
- {plothist-1.6.0 → plothist-1.7.0}/pyproject.toml +0 -1
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/__init__.py +3 -6
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/_version.py +16 -3
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/2d_hist_correlations.py +2 -2
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/histogramming.py +8 -2
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/variable_registry.py +32 -9
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_boost_histogram_version.py +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison.py +5 -5
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison_efficiency.py +1 -1
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_histogramming.py +17 -9
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_plothist_style.py +7 -7
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_plotters.py +11 -9
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_variable_registry.py +116 -17
- plothist-1.6.0/AUTHORS.md +0 -2
- plothist-1.6.0/docs/img/2d_hist_correlations_0.png +0 -0
- plothist-1.6.0/docs/img/2d_hist_correlations_1.png +0 -0
- plothist-1.6.0/docs/img/2d_hist_correlations_2.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/.github/ISSUE_TEMPLATE/user-story.md +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/.github/dependabot.yaml +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/.github/release.yaml +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/.gitignore +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/.readthedocs.yaml +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/CITATION.cff +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/LICENSE +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/codecov.yml +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/CONTRIBUTING.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/advanced/model_examples.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/advanced/other_advanced.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/basics/1d_func.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/basics/1d_hist.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/basics/2d_hist.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/conf.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/documentation/documentation.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/documentation/statistics.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/documentation/troubleshooting.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_advanced.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_advanced.svg +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_asymmetry.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_difference.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_efficiency.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_only_efficiency.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_pull.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_ratio.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_relative_difference.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_comparison_split_ratio.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_elt1.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_elt1_stacked.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_elt2.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_hist_simple.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_int_category.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_profile.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_side_by_side.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_side_by_side_with_numbers.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/1d_str_category.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/2d_hist_simple.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/2d_hist_simple_discrete_colormap.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/2d_hist_uneven.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/2d_hist_with_projections.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/2d_hist_with_projections.svg +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/add_text_example.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/asymmetry_comparison_advanced.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/color_palette_hists.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/fct_1d.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/fct_1d_stacked.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/matplotlib_example.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_all_comparisons.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_all_comparisons_no_model_unc.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_flatten2D.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_pull.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_pull_no_model_unc.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_stacked.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_stacked.svg +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_stacked_unstacked.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_examples_unstacked.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_with_stacked_and_unstacked_function_components.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/model_with_stacked_and_unstacked_histograms_components.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/plothist_example.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/pyhf_example.svg +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/ratio_data_vs_model_with_stacked_and_unstacked_function_components.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/savefig_comparisons.gif +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/uncertainty_types.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/usage_YlGnBu_r_palette.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/usage_coolwarm_palette.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/usage_cubehelix.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/usage_style_cycle.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/img/usage_viridis_palette.png +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/index.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/usage/plot_fitting_results.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/usage/style.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/docs/usage/utilities.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/noxfile.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/_version.pyi +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/comparison.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/default_style.mplstyle +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_asymmetry.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_difference.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_efficiency.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_only_efficiency.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_pull.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_ratio.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_relative_difference.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_comparison_split_ratio.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_elt1.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_elt1_stacked.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_elt2.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_hist_simple.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_int_category.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_profile.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_side_by_side.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/1d_str_category.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/1d_hist/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/2d_hist_simple.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/2d_hist_simple_discrete_colormap.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/2d_hist_uneven.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/2d_hist_with_projections.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/2d_hist/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/advanced/1d_comparison_advanced.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/advanced/1d_side_by_side_with_numbers.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/advanced/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/advanced/asymmetry_comparison_advanced.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/advanced/model_examples_flatten2D.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/func_1d/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/func_1d/fct_1d.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/func_1d/fct_1d_stacked.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_all_comparisons.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_all_comparisons_no_model_unc.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_examples_pull.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_examples_pull_no_model_unc.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_examples_stacked.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_examples_stacked_unstacked.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_examples_unstacked.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_with_stacked_and_unstacked_function_components.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/model_with_stacked_and_unstacked_histograms_components.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/model_ex/ratio_data_vs_model_with_stacked_and_unstacked_function_components.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/README.rst +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/add_text_example.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/color_palette_hists.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/color_palette_squares.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/matplotlib_vs_plothist_style.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/examples/utility/uncertainty_types.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/plothist_style.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/plotters.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/src/plothist/test_helpers.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison_asymmetry.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison_difference.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison_pull.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_comparison_ratio.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_1d_hist.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_2d_hist.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_advanced.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_data_model.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_func_1d.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_examples_utility.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_fonts.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_get_data.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/tests/test_test_helpers.py +0 -0
- {plothist-1.6.0 → plothist-1.7.0}/uv.lock +0 -0
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
19
|
with:
|
|
20
20
|
persist-credentials: false
|
|
21
21
|
- name: Install uv and set the python version
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
|
|
47
47
|
steps:
|
|
48
48
|
- name: Download all the dists
|
|
49
|
-
uses: actions/download-artifact@
|
|
49
|
+
uses: actions/download-artifact@v5
|
|
50
50
|
with:
|
|
51
51
|
name: python-package-distributions
|
|
52
52
|
path: dist/
|
|
@@ -71,7 +71,7 @@ jobs:
|
|
|
71
71
|
|
|
72
72
|
steps:
|
|
73
73
|
- name: Download all the dists
|
|
74
|
-
uses: actions/download-artifact@
|
|
74
|
+
uses: actions/download-artifact@v5
|
|
75
75
|
with:
|
|
76
76
|
name: python-package-distributions
|
|
77
77
|
path: dist/
|
|
@@ -5,7 +5,7 @@ ci:
|
|
|
5
5
|
|
|
6
6
|
repos:
|
|
7
7
|
- repo: https://github.com/adamchainz/blacken-docs
|
|
8
|
-
rev: "1.
|
|
8
|
+
rev: "1.20.0"
|
|
9
9
|
hooks:
|
|
10
10
|
- id: blacken-docs
|
|
11
11
|
args: ["--line-length", "120"]
|
|
@@ -13,7 +13,7 @@ repos:
|
|
|
13
13
|
- black==24.2.0
|
|
14
14
|
|
|
15
15
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
16
|
-
rev:
|
|
16
|
+
rev: v6.0.0
|
|
17
17
|
hooks:
|
|
18
18
|
- id: check-added-large-files
|
|
19
19
|
- id: check-case-conflict
|
|
@@ -30,7 +30,7 @@ repos:
|
|
|
30
30
|
args: ["--pytest-test-first"]
|
|
31
31
|
|
|
32
32
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
33
|
-
rev: v0.
|
|
33
|
+
rev: v0.13.3
|
|
34
34
|
hooks:
|
|
35
35
|
- id: ruff
|
|
36
36
|
args: ["--fix", "--show-fixes"]
|
|
@@ -44,13 +44,13 @@ repos:
|
|
|
44
44
|
- tomli
|
|
45
45
|
|
|
46
46
|
- repo: https://github.com/python-jsonschema/check-jsonschema
|
|
47
|
-
rev: 0.
|
|
47
|
+
rev: 0.34.0
|
|
48
48
|
hooks:
|
|
49
49
|
- id: check-github-workflows
|
|
50
50
|
args: ["--verbose"]
|
|
51
51
|
|
|
52
52
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
53
|
-
rev: v1.
|
|
53
|
+
rev: v1.18.2
|
|
54
54
|
hooks:
|
|
55
55
|
- id: mypy
|
|
56
56
|
files: src
|
|
@@ -66,13 +66,13 @@ repos:
|
|
|
66
66
|
- id: rst-inline-touching-normal
|
|
67
67
|
|
|
68
68
|
- repo: https://github.com/python-jsonschema/check-jsonschema
|
|
69
|
-
rev: 0.
|
|
69
|
+
rev: 0.34.0
|
|
70
70
|
hooks:
|
|
71
71
|
- id: check-readthedocs
|
|
72
72
|
- id: check-dependabot
|
|
73
73
|
- id: check-github-workflows
|
|
74
74
|
|
|
75
75
|
- repo: https://github.com/henryiii/validate-pyproject-schema-store
|
|
76
|
-
rev: 2025.
|
|
76
|
+
rev: 2025.10.03
|
|
77
77
|
hooks:
|
|
78
78
|
- id: validate-pyproject
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
For contributing, refer to the chapter [Contributing](https://plothist.readthedocs.io/en/latest/CONTRIBUTING.html) in the documentation.
|
|
@@ -25,7 +25,7 @@ For each variable in the list, the following information is stored by default in
|
|
|
25
25
|
|
|
26
26
|
variable_0:
|
|
27
27
|
name: variable_0
|
|
28
|
-
bins:
|
|
28
|
+
bins: auto
|
|
29
29
|
range:
|
|
30
30
|
- min
|
|
31
31
|
- max
|
|
@@ -63,24 +63,24 @@ Update the registry
|
|
|
63
63
|
|
|
64
64
|
Multiple functions are available to modify the plotting information of the variables in the registry, add or remove some parameters.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
Binning and ranges
|
|
67
|
+
------------------
|
|
68
68
|
|
|
69
|
-
The :func:`
|
|
69
|
+
The :func:`update_variable_registry_binning() <plothist.variable_registry.update_variable_registry_binning>` function automatically updates the number of bins parameter in the ``yaml`` file to the length of [``numpy.histogram_bin_edges``](https://numpy.org/doc/2.1/reference/generated/numpy.histogram_bin_edges.html#numpy-histogram-bin-edges) minus one (the bins are regular) and automatically updates the range parameter in the ``yaml`` file to the ``min`` and ``max`` values of the variable in the dataset:
|
|
70
70
|
|
|
71
71
|
.. code-block:: python
|
|
72
72
|
|
|
73
|
-
from plothist import
|
|
73
|
+
from plothist import update_variable_registry_binning
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
update_variable_registry_binning(df, variable_keys)
|
|
76
76
|
|
|
77
|
-
The range has been updated for all the variables in ``variables_keys``. The ``yaml`` file is now:
|
|
77
|
+
The number of bins and the range has been updated for all the variables in ``variables_keys``. The ``yaml`` file is now:
|
|
78
78
|
|
|
79
79
|
.. code-block:: yaml
|
|
80
80
|
|
|
81
81
|
variable_0:
|
|
82
82
|
name: variable_0
|
|
83
|
-
bins:
|
|
83
|
+
bins: 121 # = len(numpy.histogram_bin_edges(df["variable_0"], bins="auto")) - 1
|
|
84
84
|
range:
|
|
85
85
|
- -10.55227774892869 # min(df["variable_0"])
|
|
86
86
|
- 10.04658448558009 # max(df["variable_0"])
|
|
@@ -94,10 +94,9 @@ The range has been updated for all the variables in ``variables_keys``. The ``ya
|
|
|
94
94
|
variable_1:
|
|
95
95
|
...
|
|
96
96
|
|
|
97
|
-
Then, you may manually modify the ``yaml`` to get a more suitable range to display in the plot.
|
|
98
|
-
|
|
99
|
-
Calling this function again on the same variable keys will not overwrite their ``range`` parameter, unless the ``overwrite`` parameter is set to ``True``.
|
|
97
|
+
Then, you may manually modify the ``yaml`` to get a more suitable binning and range to display in the plot.
|
|
100
98
|
|
|
99
|
+
Calling this function again on the same variable keys will not overwrite their ``bins`` or ``range`` parameter, unless the ``overwrite`` parameter is set to ``True``.
|
|
101
100
|
|
|
102
101
|
Add or modify variable properties
|
|
103
102
|
---------------------------------
|
|
@@ -124,7 +123,7 @@ This will add the new properties to the ``yaml`` file to all the variables in ``
|
|
|
124
123
|
|
|
125
124
|
variable_0:
|
|
126
125
|
name: variable_0
|
|
127
|
-
bins:
|
|
126
|
+
bins: 121
|
|
128
127
|
range:
|
|
129
128
|
- -10.55227774892869
|
|
130
129
|
- 10.04658448558009
|
|
@@ -160,7 +159,7 @@ To remove a parameter from the plotting information, you can use the :func:`remo
|
|
|
160
159
|
|
|
161
160
|
from plothist import remove_variable_registry_parameters
|
|
162
161
|
|
|
163
|
-
remove_variable_registry_parameters(["range", "log", "legend_ncols", "new_property"], variable_keys)
|
|
162
|
+
remove_variable_registry_parameters(["bins", "range", "log", "legend_ncols", "new_property"], variable_keys)
|
|
164
163
|
|
|
165
164
|
The ``yaml`` file is updated:
|
|
166
165
|
|
|
@@ -168,7 +167,6 @@ The ``yaml`` file is updated:
|
|
|
168
167
|
|
|
169
168
|
variable_0:
|
|
170
169
|
name: variable_0
|
|
171
|
-
bins: 50
|
|
172
170
|
label: variable_0
|
|
173
171
|
legend_location: best
|
|
174
172
|
docstring: ''
|
|
@@ -197,7 +195,7 @@ Here is an example of how to create, update, and use the variable registry to pl
|
|
|
197
195
|
plot_hist,
|
|
198
196
|
create_variable_registry,
|
|
199
197
|
update_variable_registry,
|
|
200
|
-
|
|
198
|
+
update_variable_registry_binning,
|
|
201
199
|
get_variable_from_registry,
|
|
202
200
|
add_text,
|
|
203
201
|
)
|
|
@@ -208,8 +206,8 @@ Here is an example of how to create, update, and use the variable registry to pl
|
|
|
208
206
|
# Create the registry
|
|
209
207
|
create_variable_registry(variable_keys)
|
|
210
208
|
|
|
211
|
-
# Update the
|
|
212
|
-
|
|
209
|
+
# Update the number of bins and range
|
|
210
|
+
update_variable_registry_binning(df, variable_keys)
|
|
213
211
|
|
|
214
212
|
# Add custom info
|
|
215
213
|
update_variable_registry({"text": "my analysis"}, variable_keys)
|
|
@@ -245,7 +243,7 @@ Example: to plot a zoom on a variable but still keep the original one, you can c
|
|
|
245
243
|
|
|
246
244
|
variable_0:
|
|
247
245
|
name: variable_0
|
|
248
|
-
bins:
|
|
246
|
+
bins: 121
|
|
249
247
|
range:
|
|
250
248
|
- -10
|
|
251
249
|
- 10
|
|
@@ -257,7 +255,7 @@ Example: to plot a zoom on a variable but still keep the original one, you can c
|
|
|
257
255
|
|
|
258
256
|
variable_0_zoom:
|
|
259
257
|
name: variable_0
|
|
260
|
-
bins:
|
|
258
|
+
bins: 121
|
|
261
259
|
range:
|
|
262
260
|
- -1
|
|
263
261
|
- 1
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -64,11 +64,11 @@ To update ``plothist`` to its latest stable version, follow the instructions abo
|
|
|
64
64
|
Install the development version
|
|
65
65
|
===============================
|
|
66
66
|
|
|
67
|
-
1.
|
|
67
|
+
1. `Fork <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo?tool=webui>`_ and clone locally the plothist repository, then go to the package folder:
|
|
68
68
|
|
|
69
69
|
.. code-block:: bash
|
|
70
70
|
|
|
71
|
-
git clone git@github.com:
|
|
71
|
+
git clone git@github.com:USERNAME/plothist.git
|
|
72
72
|
|
|
73
73
|
cd plothist
|
|
74
74
|
|
|
@@ -9,12 +9,7 @@ from .comparison import (
|
|
|
9
9
|
get_ratio,
|
|
10
10
|
get_ratio_variances,
|
|
11
11
|
)
|
|
12
|
-
from .histogramming import
|
|
13
|
-
create_axis,
|
|
14
|
-
flatten_2d_hist,
|
|
15
|
-
make_2d_hist,
|
|
16
|
-
make_hist,
|
|
17
|
-
)
|
|
12
|
+
from .histogramming import create_axis, flatten_2d_hist, make_2d_hist, make_hist
|
|
18
13
|
from .plothist_style import (
|
|
19
14
|
add_luminosity,
|
|
20
15
|
add_text,
|
|
@@ -43,6 +38,7 @@ from .variable_registry import (
|
|
|
43
38
|
get_variable_from_registry,
|
|
44
39
|
remove_variable_registry_parameters,
|
|
45
40
|
update_variable_registry,
|
|
41
|
+
update_variable_registry_binning,
|
|
46
42
|
update_variable_registry_ranges,
|
|
47
43
|
)
|
|
48
44
|
|
|
@@ -81,6 +77,7 @@ __all__ = [
|
|
|
81
77
|
"set_fitting_ylabel_fontsize",
|
|
82
78
|
"set_style",
|
|
83
79
|
"update_variable_registry",
|
|
80
|
+
"update_variable_registry_binning",
|
|
84
81
|
"update_variable_registry_ranges",
|
|
85
82
|
]
|
|
86
83
|
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
5
12
|
|
|
6
13
|
TYPE_CHECKING = False
|
|
7
14
|
if TYPE_CHECKING:
|
|
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
|
|
|
9
16
|
from typing import Union
|
|
10
17
|
|
|
11
18
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
12
20
|
else:
|
|
13
21
|
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
14
23
|
|
|
15
24
|
version: str
|
|
16
25
|
__version__: str
|
|
17
26
|
__version_tuple__: VERSION_TUPLE
|
|
18
27
|
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
19
30
|
|
|
20
|
-
__version__ = version = '1.
|
|
21
|
-
__version_tuple__ = version_tuple = (1,
|
|
31
|
+
__version__ = version = '1.7.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 7, 0)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -20,7 +20,7 @@ from plothist import (
|
|
|
20
20
|
get_variable_from_registry,
|
|
21
21
|
make_2d_hist,
|
|
22
22
|
plot_2d_hist,
|
|
23
|
-
|
|
23
|
+
update_variable_registry_binning,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
# No need to redo this step if the registry was already created before
|
|
@@ -28,7 +28,7 @@ variable_keys = ["variable_0", "variable_1", "variable_2"]
|
|
|
28
28
|
unique_id = str(int(time.time() * 1000))[-8:] # unique ID based on current time
|
|
29
29
|
temporary_registry_path = f"./_temporary_variable_registry_{unique_id}.yaml"
|
|
30
30
|
create_variable_registry(variable_keys, path=temporary_registry_path)
|
|
31
|
-
|
|
31
|
+
update_variable_registry_binning(df, variable_keys, path=temporary_registry_path)
|
|
32
32
|
|
|
33
33
|
# Get all the correlation plot between the variables
|
|
34
34
|
variable_keys_combinations = list(combinations(variable_keys, 2))
|
|
@@ -109,6 +109,7 @@ def make_hist(
|
|
|
109
109
|
bins: int | list[float] | np.ndarray = 50,
|
|
110
110
|
range: tuple[float | str, float | str] | None = None,
|
|
111
111
|
weights: float | list[float] | np.ndarray = 1,
|
|
112
|
+
mute_warning: bool = False,
|
|
112
113
|
) -> bh.Histogram:
|
|
113
114
|
"""
|
|
114
115
|
Create a histogram object and fill it with the provided data.
|
|
@@ -129,6 +130,8 @@ def make_hist(
|
|
|
129
130
|
Weight(s) to apply to the data points (default is 1).
|
|
130
131
|
If a float, a single weight is applied to all data points.
|
|
131
132
|
If an array-like, weights are applied element-wise.
|
|
133
|
+
mute_warning : bool, optional
|
|
134
|
+
Whether to mute warnings about data outside the binning range (default is False).
|
|
132
135
|
|
|
133
136
|
Returns
|
|
134
137
|
-------
|
|
@@ -160,7 +163,7 @@ def make_hist(
|
|
|
160
163
|
range_coverage = h.sum().value / n_data
|
|
161
164
|
|
|
162
165
|
# Issue a warning if more than 1% of the data is outside of the binning range
|
|
163
|
-
if range_coverage < 0.99:
|
|
166
|
+
if range_coverage < 0.99 and not mute_warning:
|
|
164
167
|
warnings.warn(
|
|
165
168
|
f"Only {100 * range_coverage:.2f}% of data contained in the binning range [{axis.edges[0]}, {axis.edges[-1]}].",
|
|
166
169
|
category=RangeWarning,
|
|
@@ -177,6 +180,7 @@ def make_2d_hist(
|
|
|
177
180
|
tuple[float | str, float | str] | None, tuple[float | str, float | str] | None
|
|
178
181
|
] = (None, None),
|
|
179
182
|
weights: float | list[float] | np.ndarray = 1,
|
|
183
|
+
mute_warning: bool = False,
|
|
180
184
|
) -> bh.Histogram:
|
|
181
185
|
"""
|
|
182
186
|
Create a 2D histogram object and fill it with the provided data.
|
|
@@ -198,6 +202,8 @@ def make_2d_hist(
|
|
|
198
202
|
Weight(s) to apply to the data points (default is 1).
|
|
199
203
|
If a float, a single weight is applied to all data points.
|
|
200
204
|
If an array-like, weights are applied element-wise.
|
|
205
|
+
mute_warning : bool, optional
|
|
206
|
+
Whether to mute warnings about data outside the binning range (default is False).
|
|
201
207
|
|
|
202
208
|
Returns
|
|
203
209
|
-------
|
|
@@ -245,7 +251,7 @@ def make_2d_hist(
|
|
|
245
251
|
range_coverage = h.sum().value / n_data
|
|
246
252
|
|
|
247
253
|
# Issue a warning if more than 1% of the data is outside of the binning range
|
|
248
|
-
if range_coverage < 0.99:
|
|
254
|
+
if range_coverage < 0.99 and not mute_warning:
|
|
249
255
|
warnings.warn(
|
|
250
256
|
f"Only {100 * range_coverage:.2f}% of data contained in the binning range ([{x_axis.edges[0]}, {x_axis.edges[-1]}], [{y_axis.edges[0]}, {y_axis.edges[-1]}]).",
|
|
251
257
|
category=RangeWarning,
|
|
@@ -8,6 +8,7 @@ import os
|
|
|
8
8
|
import warnings
|
|
9
9
|
|
|
10
10
|
import boost_histogram as bh
|
|
11
|
+
import numpy as np
|
|
11
12
|
import yaml
|
|
12
13
|
|
|
13
14
|
from plothist.histogramming import create_axis
|
|
@@ -126,7 +127,7 @@ def create_variable_registry(
|
|
|
126
127
|
{
|
|
127
128
|
variable_key: {
|
|
128
129
|
"name": variable_key,
|
|
129
|
-
"bins":
|
|
130
|
+
"bins": "auto",
|
|
130
131
|
"range": ("min", "max"),
|
|
131
132
|
"label": variable_key,
|
|
132
133
|
"log": False,
|
|
@@ -259,25 +260,37 @@ def remove_variable_registry_parameters(
|
|
|
259
260
|
_save_variable_registry(variable_registry, path=path)
|
|
260
261
|
|
|
261
262
|
|
|
262
|
-
def update_variable_registry_ranges(
|
|
263
|
+
def update_variable_registry_ranges(*args, **kwargs):
|
|
264
|
+
warnings.warn(
|
|
265
|
+
"`update_variable_registry_ranges` is deprecated since v1.7.0 and will be removed in future versions. "
|
|
266
|
+
"Use `update_variable_registry_binning` instead.",
|
|
267
|
+
DeprecationWarning,
|
|
268
|
+
stacklevel=2,
|
|
269
|
+
)
|
|
270
|
+
return update_variable_registry_binning(*args, **kwargs)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def update_variable_registry_binning(
|
|
263
274
|
data,
|
|
264
275
|
variable_keys: list[str] | None = None,
|
|
265
276
|
path: str = "./variable_registry.yaml",
|
|
266
277
|
overwrite: bool = False,
|
|
267
278
|
) -> None:
|
|
268
279
|
"""
|
|
269
|
-
Update the range parameters for multiple variables in the variable registry file.
|
|
280
|
+
Update both the bins and range parameters for multiple variables in the variable registry file.
|
|
270
281
|
|
|
271
282
|
Parameters
|
|
272
283
|
----------
|
|
273
284
|
data : numpy.ndarray or pandas.DataFrame
|
|
274
285
|
A dataset containing the data for the variables.
|
|
275
286
|
variable_keys : list[str]
|
|
276
|
-
A list of variable keys for which to update the
|
|
287
|
+
A list of variable keys for which to update the parameters in the registry.
|
|
288
|
+
The variable needs to have a bin and range properties in the registry.
|
|
289
|
+
Default is None: all variables in the registry are updated.
|
|
277
290
|
path : str, optional
|
|
278
291
|
The path to the variable registry file (default is "./variable_registry.yaml").
|
|
279
292
|
overwrite : bool, optional
|
|
280
|
-
If True, the range parameters will be overwritten even if
|
|
293
|
+
If True, the bin and range parameters will be overwritten even if they differ from "auto" and ("min", "max") (default is False).
|
|
281
294
|
|
|
282
295
|
Returns
|
|
283
296
|
-------
|
|
@@ -302,13 +315,23 @@ def update_variable_registry_ranges(
|
|
|
302
315
|
f"Variable {variable_key} does not have a name, bins or range property in the registry {path}."
|
|
303
316
|
)
|
|
304
317
|
|
|
305
|
-
|
|
318
|
+
bins = "auto" if overwrite else variable["bins"]
|
|
319
|
+
bin_number = len(np.histogram_bin_edges(data[variable["name"]], bins=bins)) - 1
|
|
306
320
|
|
|
307
|
-
|
|
308
|
-
|
|
321
|
+
range_val = ("min", "max") if overwrite else variable["range"]
|
|
322
|
+
|
|
323
|
+
if bins == "auto" or tuple(range_val) == ("min", "max"):
|
|
324
|
+
axis = create_axis(
|
|
325
|
+
bin_number,
|
|
326
|
+
tuple(range_val),
|
|
327
|
+
data[variable["name"]],
|
|
328
|
+
)
|
|
309
329
|
if isinstance(axis, bh.axis.Regular):
|
|
310
330
|
update_variable_registry(
|
|
311
|
-
{
|
|
331
|
+
{
|
|
332
|
+
"bins": bin_number,
|
|
333
|
+
"range": (float(axis.edges[0]), float(axis.edges[-1])),
|
|
334
|
+
},
|
|
312
335
|
[variable_key],
|
|
313
336
|
path=path,
|
|
314
337
|
overwrite=True,
|
|
@@ -11,6 +11,6 @@ def test_import_plothist_version_too_low(monkeypatch: pytest.MonkeyPatch) -> Non
|
|
|
11
11
|
# pop sys.modules to force re-import
|
|
12
12
|
sys.modules.pop("plothist", None)
|
|
13
13
|
with pytest.raises(
|
|
14
|
-
ImportError, match="The version of boost_histogram is lower than 1.4.0"
|
|
14
|
+
ImportError, match=r"The version of boost_histogram is lower than 1.4.0"
|
|
15
15
|
):
|
|
16
16
|
import plothist # noqa: F401
|
|
@@ -12,7 +12,7 @@ from plothist.comparison import (
|
|
|
12
12
|
def test_check_uncertainty_type_invalid():
|
|
13
13
|
with pytest.raises(
|
|
14
14
|
ValueError,
|
|
15
|
-
match="Uncertainty type invalid_type not valid. Must be in",
|
|
15
|
+
match=r"Uncertainty type invalid_type not valid. Must be in",
|
|
16
16
|
):
|
|
17
17
|
_check_uncertainty_type("invalid_type")
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ def test_get_asymmetrical_uncertainties_invalid():
|
|
|
21
21
|
h1 = bh.Histogram(bh.axis.Regular(10, 0, 1))
|
|
22
22
|
with pytest.raises(
|
|
23
23
|
ValueError,
|
|
24
|
-
match="Invalid uncertainty type 'symmetrical' for asymmetrical uncertainties.",
|
|
24
|
+
match=r"Invalid uncertainty type 'symmetrical' for asymmetrical uncertainties.",
|
|
25
25
|
):
|
|
26
26
|
get_asymmetrical_uncertainties(h1, uncertainty_type="symmetrical")
|
|
27
27
|
|
|
@@ -29,19 +29,19 @@ def test_get_asymmetrical_uncertainties_invalid():
|
|
|
29
29
|
def test_check_binning_consistency_dimensionality():
|
|
30
30
|
h1 = bh.Histogram(bh.axis.Regular(10, 0, 1))
|
|
31
31
|
h2 = bh.Histogram(bh.axis.Regular(10, 0, 1), bh.axis.Regular(5, 0, 5))
|
|
32
|
-
with pytest.raises(ValueError, match="Histograms must have same dimensionality."):
|
|
32
|
+
with pytest.raises(ValueError, match=r"Histograms must have same dimensionality."):
|
|
33
33
|
_check_binning_consistency([h1, h2])
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def test_check_binning_consistency_bins():
|
|
37
37
|
h1 = bh.Histogram(bh.axis.Regular(10, 0, 1))
|
|
38
38
|
h2 = bh.Histogram(bh.axis.Regular(5, 0, 1))
|
|
39
|
-
with pytest.raises(ValueError, match="The bins of the histograms must be equal."):
|
|
39
|
+
with pytest.raises(ValueError, match=r"The bins of the histograms must be equal."):
|
|
40
40
|
_check_binning_consistency([h1, h2])
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def test_invalid_comparison_type():
|
|
44
44
|
h1 = bh.Histogram(bh.axis.Regular(10, 0, 1))
|
|
45
45
|
h2 = bh.Histogram(bh.axis.Regular(10, 0, 1))
|
|
46
|
-
with pytest.raises(ValueError, match="invalid not available as a comparison"):
|
|
46
|
+
with pytest.raises(ValueError, match=r"invalid not available as a comparison"):
|
|
47
47
|
get_comparison(h1, h2, comparison="invalid")
|
|
@@ -29,7 +29,7 @@ def test_get_efficiency_negative_bin_content() -> None:
|
|
|
29
29
|
h1[:] = np.c_[[-1.0], [-1.0]]
|
|
30
30
|
with pytest.raises(
|
|
31
31
|
ValueError,
|
|
32
|
-
match="can only be computed if the bin contents of both histograms are positive or zero",
|
|
32
|
+
match=r"can only be computed if the bin contents of both histograms are positive or zero",
|
|
33
33
|
):
|
|
34
34
|
get_comparison(h1, h2, comparison="efficiency")
|
|
35
35
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
3
5
|
import boost_histogram as bh
|
|
4
6
|
import numpy as np
|
|
5
7
|
import pytest
|
|
@@ -95,6 +97,10 @@ def test_range_coverage_warning() -> None:
|
|
|
95
97
|
_ = make_hist(data=[0, 1, 2, 3, 10], bins=5, range=(0, 5))
|
|
96
98
|
assert str(warn_info[0].message) == warn_message
|
|
97
99
|
|
|
100
|
+
with warnings.catch_warnings():
|
|
101
|
+
warnings.simplefilter("error")
|
|
102
|
+
_ = make_hist(data=[0, 1, 2, 3, 10], bins=5, range=(0, 5), mute_warning=True)
|
|
103
|
+
|
|
98
104
|
with pytest.warns(Warning) as warn_info:
|
|
99
105
|
_ = make_hist(data=[0, 1, 2, 3, 10], bins=5, range=(0, 5), weights=2)
|
|
100
106
|
assert str(warn_info[0].message) == warn_message
|
|
@@ -139,18 +145,20 @@ def test_warning_when_range_is_provided_with_variable_bins() -> None:
|
|
|
139
145
|
bins = [1, 2, 3, 4]
|
|
140
146
|
range_value = (0, 5)
|
|
141
147
|
|
|
142
|
-
with pytest.warns(Warning, match="Custom binning -> ignore supplied range"):
|
|
148
|
+
with pytest.warns(Warning, match=r"Custom binning -> ignore supplied range"):
|
|
143
149
|
create_axis(bins=bins, range=range_value)
|
|
144
150
|
|
|
145
151
|
|
|
146
152
|
def test_invalid_bins() -> None:
|
|
147
153
|
"""Test for non-positive bins."""
|
|
148
154
|
with pytest.raises(
|
|
149
|
-
ValueError, match="Number of bins must be positive, but got -5."
|
|
155
|
+
ValueError, match=r"Number of bins must be positive, but got -5."
|
|
150
156
|
):
|
|
151
157
|
create_axis(bins=-5)
|
|
152
158
|
|
|
153
|
-
with pytest.raises(
|
|
159
|
+
with pytest.raises(
|
|
160
|
+
ValueError, match=r"Number of bins must be positive, but got 0."
|
|
161
|
+
):
|
|
154
162
|
create_axis(bins=0)
|
|
155
163
|
|
|
156
164
|
|
|
@@ -158,7 +166,7 @@ def test_range_min_max_with_empty_data() -> None:
|
|
|
158
166
|
"""Test for using 'min' or 'max' in range with empty data."""
|
|
159
167
|
with pytest.raises(
|
|
160
168
|
ValueError,
|
|
161
|
-
match="Cannot use 'min'/'max' range values with empty data. "
|
|
169
|
+
match=r"Cannot use 'min'/'max' range values with empty data. "
|
|
162
170
|
"Please supply a range or provide data.",
|
|
163
171
|
):
|
|
164
172
|
create_axis(bins=5, range=("min", "max"), data=[])
|
|
@@ -230,7 +238,7 @@ def test_make_make_2d_hist_with_invalid_data_dimensions() -> None:
|
|
|
230
238
|
"""
|
|
231
239
|
Test make_hist() with invalid data dimensions.
|
|
232
240
|
"""
|
|
233
|
-
with pytest.raises(ValueError, match="data should have two components, x and y"):
|
|
241
|
+
with pytest.raises(ValueError, match=r"data should have two components, x and y"):
|
|
234
242
|
make_2d_hist(data=[1, 2, 3], bins=5, range=(0, 5))
|
|
235
243
|
|
|
236
244
|
|
|
@@ -238,14 +246,14 @@ def test_make_2d_hist_with_different_x_y_lengths() -> None:
|
|
|
238
246
|
"""
|
|
239
247
|
Test make_2d_hist() with different lengths of x and y data.
|
|
240
248
|
"""
|
|
241
|
-
with pytest.raises(ValueError, match="x and y must have the same length"):
|
|
249
|
+
with pytest.raises(ValueError, match=r"x and y must have the same length"):
|
|
242
250
|
make_2d_hist(data=[[1, 2, 3], [4, 5]], bins=(5, 5), range=((0, 5), (0, 5)))
|
|
243
251
|
|
|
244
252
|
|
|
245
253
|
def test_check_counting_histogram_invalid() -> None:
|
|
246
254
|
"""Test that _check_counting_histogram raises ValueError for non-counting histogram."""
|
|
247
255
|
hist = bh.Histogram(bh.axis.Regular(10, 0, 1), storage=bh.storage.Mean())
|
|
248
|
-
with pytest.raises(ValueError, match="The histogram must be a counting histogram"):
|
|
256
|
+
with pytest.raises(ValueError, match=r"The histogram must be a counting histogram"):
|
|
249
257
|
_check_counting_histogram(hist)
|
|
250
258
|
|
|
251
259
|
|
|
@@ -256,12 +264,12 @@ def test_make_hist_from_function_raises_on_non_1d_hist() -> None:
|
|
|
256
264
|
def func(x):
|
|
257
265
|
return x**2
|
|
258
266
|
|
|
259
|
-
with pytest.raises(ValueError, match="The reference histogram must be 1D."):
|
|
267
|
+
with pytest.raises(ValueError, match=r"The reference histogram must be 1D."):
|
|
260
268
|
_make_hist_from_function(func, hist_2d)
|
|
261
269
|
|
|
262
270
|
|
|
263
271
|
def test_flatten_2d_hist_raises_on_1d_hist() -> None:
|
|
264
272
|
"""Test that flatten_2d_hist raises ValueError if the input histogram is not 2D."""
|
|
265
273
|
hist_1d = make_hist()
|
|
266
|
-
with pytest.raises(ValueError, match="The input histogram must be 2D."):
|
|
274
|
+
with pytest.raises(ValueError, match=r"The input histogram must be 2D."):
|
|
267
275
|
flatten_2d_hist(hist_1d)
|