Skip to content

Commit 25bcfdc

Browse files
committed
add test
1 parent 1f6f42a commit 25bcfdc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/frame/methods/test_sample.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ 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 = "Invalid weights: If `replace`=True sum of weights must be less than 1"
145+
with pytest.raises(ValueError, match=msg):
146+
obj.sample(n=3, weights=weights_large_total, replace=True)
147+
140148
def test_sample_zero_weights(self, obj):
141149
# All zeros raises errors
142150

0 commit comments

Comments
 (0)