Skip to content

Commit d838bbf

Browse files
authored
tests: add neg integer test (#641)
1 parent 67be0a2 commit d838bbf

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### User changes
88
* Python 3.10 officially supported, with wheels.
99
* Support subtraction on histograms [#636][]
10+
* Integer histograms are now signed [#636][]
1011

1112
#### Bug fixes
1213
* Support custom setters on AxesTuple subclasses. [#627][]

tests/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ def metadata(request):
4343
)
4444
def count_storage(request):
4545
return request.param
46+
47+
48+
@pytest.fixture(
49+
params=(
50+
bh.storage.Double,
51+
bh.storage.Int64,
52+
bh.storage.AtomicInt64,
53+
bh.storage.Unlimited,
54+
),
55+
ids=("Double", "Int64", "AtomicInt64", "Unlimited"),
56+
)
57+
def count_single_storage(request):
58+
return request.param

tests/test_histogram.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,8 @@ def test_fill_1d(flow):
152152
assert get(h, bh.overflow) == 1
153153

154154

155-
@pytest.mark.parametrize(
156-
"storage",
157-
[bh.storage.Int64, bh.storage.Double, bh.storage.Unlimited, bh.storage.AtomicInt64],
158-
)
159-
def test_setting(storage):
160-
h = bh.Histogram(bh.axis.Regular(10, 0, 1), storage=storage())
155+
def test_setting(count_single_storage):
156+
h = bh.Histogram(bh.axis.Regular(10, 0, 1), storage=count_single_storage())
161157
h[bh.underflow] = 1
162158
h[0] = 2
163159
h[1] = 3
@@ -1284,3 +1280,12 @@ def test_sum_empty_axis():
12841280
)
12851281
assert hist.sum().value == 0
12861282
assert "Str" in repr(hist)
1283+
1284+
1285+
# Issue 618
1286+
def test_negative_fill(count_storage):
1287+
h = bh.Histogram(bh.axis.Integer(0, 3), storage=count_storage())
1288+
h.fill(1, weight=-1)
1289+
1290+
answer = np.array([0, -1, 0])
1291+
assert h.values() == approx(answer)

0 commit comments

Comments
 (0)