Skip to content

[BUG] Cannot pick a single value if that value is overflow/underflow #574

@henryiii

Description

@henryiii

Currently, since using using Boost.Histogram's slicing as the backend, it has become impossible to "pick" an axis on an overflow or underflow bin. The following code fails:

def test_pick_flowbin():
    w = 1e-2  # e.g. a cross section for a process
    x = np.random.normal(loc=0.4, scale=0.4, size=1000)
    y = np.random.normal(loc=0.6, scale=0.4, size=1000)

    h = bh.Histogram(
        bh.axis.Regular(3, 0, 1),
        bh.axis.Regular(3, 0, 1),
        storage=bh.storage.Weight(),
    )
    h.fill(x, y, weight=w)

    uf_slice = h[bh.tag.underflow, ...]

The reason is that it is picking is implemented via a workaround - a single bin is sliced:

--------------------------------------------- Captured log call --------------------------------------------------------
DEBUG    boost_histogram._internal.hist:hist.py:778
                Reduce with [reduce_command(slice_and_rebin(iaxis=0, begin=-1, end=0, merge=1, mode=slice_mode.crop))]

For a flow bin, this is an invalid slice. This would be much easier with a "pick" of some sort from Boost.Histogram. Possibly the only fix for now would be to special case under/overflow, and implement some ugly logic for it.

Discovered on Gitter by @andrzejnovak.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions