Skip to content

Commit 3249031

Browse files
author
Kevin D Smith
committed
Fix out-of-range sampling
1 parent 6d54554 commit 3249031

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

swat/cas/table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4052,6 +4052,10 @@ def sample(self, n=None, frac=None, replace=False, weights=None,
40524052
if n is not None:
40534053
numrows = self._numrows
40544054
frac = float(n) / self._numrows
4055+
if frac <= 0:
4056+
raise RuntimeError('Sample percentage will return no samples.')
4057+
if frac >= 1:
4058+
return self._retrieve('table.partition')['casTable']
40554059

40564060
return self._sample(sample_pct=frac, sample_seed=random_state,
40574061
stratify_by=stratify_by)

0 commit comments

Comments
 (0)