Skip to content

Commit 75b81fb

Browse files
committed
Simplify condition in weighted sampling function for Semi Kazar in Week02
1 parent a616e35 commit 75b81fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Week02/weighted_semi_kazar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import random
22

33
def weighted_srs(data, n, weights, with_replacement = False):
4-
if with_replacement != True or weights is None:
4+
if not (with_replacement or weights):
55
sample = random.sample(data, n)
66
else:
77
sample = random.choices(data, weights=weights, k=n)
88

9-
return sample
9+
return sample

0 commit comments

Comments
 (0)