Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for irregular bin widths in hist.plot.plot_pull_array #369

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Commits on Jan 27, 2022

  1. Allow for irregular pull widths

    Assuming the axis has an `edges` attribute, I assume it should also have a
    `widths` attribute, so I thought we can just use that for the pull bar widths
    instead of calculating our own assuming a regular spacing (which might not be
    true).
    
    For the patch-width, we just use `right_edge - left_edge`, instead of what was
    done before, which dividing this difference by the number of pulls and then
    multiplying them again with the same number.
    meliache committed Jan 27, 2022
    Configuration menu
    Copy the full SHA
    f9d5961 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2022

  1. Configuration menu
    Copy the full SHA
    62c477d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ef4d45e View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2022

  1. Correct values with bin width when fitting curve to hist

    Necessary when doing pull plots for histograms with an axis of type
    `hist.axis.Variable` with varying bin widths.
    meliache committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    37b6d3d View commit details
    Browse the repository at this point in the history
  2. Fix typo in attribute name

    Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
    meliache and henryiii committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    f697e9e View commit details
    Browse the repository at this point in the history
  3. tests: regenerate images

    henryiii committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    e764997 View commit details
    Browse the repository at this point in the history
  4. fix: add mult

    henryiii committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    471d727 View commit details
    Browse the repository at this point in the history
  5. Refactor: Use mean instead of sum divided by length

    Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
    meliache and henryiii committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    658e2ba View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3f0e7a3 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2022

  1. Configuration menu
    Copy the full SHA
    8a470df View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2022

  1. Configuration menu
    Copy the full SHA
    18ba205 View commit details
    Browse the repository at this point in the history
  2. Test ratio_plot with variably-binned axes with a callable

    I add 2 tests
    
    - `test_image_plot_ratio_variable_axis_with_regular_bins`:
      Same as `test_image_plot_ratio_callable`, but use an `axis.Variable`, but set
      the bin edges to be regular, same as former test with `axis.Regular`. With
      this I just check that the plot doesn't depend on the axis type. For this we
      re-use the existing baseline plot.
    
    - `test_image_plot_ratio_callable_bayesian_blocks_bins`:
      Actually try the ratio plot with variable bin widths. For this I ran the
      bayesian blocks algorithm on 5000 random numbers. I used that instead of 1000
      numbers because for 1000 the binning seemed very coarse for me and the fit
      plots just looked like a triangle. For this we create a new baseline plot.
    
    Also I added a helper function to create these `plot_ratio_callable` test for
    different axes/binnings in order to avoid code duplication.
    
    TODO: The baseline plots for
    `test_image_plot_ratio_callable_bayesian_blocks_bins` looks like something is
    off, the centre pull is much larger than the pull errorbars. I have to check
    that the bin widths are correctly taken into account in the errorbars and ratios.
    meliache committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    2d598a8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0ac80f9 View commit details
    Browse the repository at this point in the history
  4. Fix the tests by using re-seeding the global bit-generator

    Most tests use `np.random.seed(42)` to re-seed the global RNG. Initially I didn't
    follow this in my tests, because according to its documentation it is not
    best-practice and a legacy function.
    
    > The best practice is to not reseed a BitGenerator, rather to recreate a new
    > one. This method is here for legacy reasons.
    
    Instead, I created a custom RNG with a seed and used that to generate my random
    numbers. However, the tests failed and I noticed that the random seed not only affects the numbers to
    fill the histogram with, but also the fit, which I can't affect via a custom RNG,
    so I have to re-seed the global RNG.
    
    Therefore, I fall back to using `np.random.normal`.
    meliache committed Mar 14, 2022
    Configuration menu
    Copy the full SHA
    6172c7e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    46c372c View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2022

  1. Fix: Take into account variable bin widths in _plot_ratiolike

    Also update baseline with fix
    meliache committed Mar 15, 2022
    Configuration menu
    Copy the full SHA
    f8bb460 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2baa648 View commit details
    Browse the repository at this point in the history