Skip to content

Commit 18b2876

Browse files
committed
add test
1 parent e5f9a07 commit 18b2876

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/methods/test_sample.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ def test_sample_inf_weights(self, obj):
137137
with pytest.raises(ValueError, match=msg):
138138
obj.sample(n=3, weights=weights_with_ninf)
139139

140+
def test_sample_replacement_weight_sum(self, obj):
141+
# GH#61516
142+
weights_large_total = [1] * 10
143+
weights_large_total[0] = 100
144+
msg = (
145+
"Invalid weights: If `replace`=False,"
146+
" unit probabilities have to be less than 1"
147+
)
148+
with pytest.raises(ValueError, match=msg):
149+
obj.sample(n=3, weights=weights_large_total, replace=False)
150+
140151
def test_sample_zero_weights(self, obj):
141152
# All zeros raises errors
142153

0 commit comments

Comments
 (0)