Skip to content

Commit b08d70a

Browse files
committed
Dont do imports in pytest
1 parent c8edd70 commit b08d70a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/Python/test_sampling.py

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

33

4-
from random import uniform, choice
5-
from numpy.random import binomial
6-
from math import inf, nan
74

85

96
def _beta_1_b(b):
@@ -30,7 +27,7 @@ def sample_isospec(formula, count, precision):
3027
#for x in population:
3128
# yield x
3229
'''Performs sampling with replacement from population argument, with
33-
associated probabilities from second argument. The probabilities must
30+
associated probabilities from second argument. The probabilities must
3431
sum to 1. Yields a stream of tuples: (population_member, times_chosen).
3532
Accepts generators as first and second argument. May return duplicate
3633
tuples and tuples with times_chosen == 0.
@@ -49,7 +46,7 @@ def sample_isospec(formula, count, precision):
4946
while (pprob - cprob) * count / (1.0 - cprob) < 1.0:
5047
cprob += _beta_1_b(count) * (1.0 - cprob)
5148
while pprob < cprob:
52-
if accumulated > 0:
49+
if accumulated > 0:
5350
yield (pop_next, accumulated)
5451
accumulated = 0
5552
pop_next, prob_next = next(iso_iter)
@@ -213,6 +210,10 @@ def sample_ciic(formula, count, precision):
213210

214211

215212
if __name__ == '__main__':
213+
from random import uniform, choice
214+
from numpy.random import binomial
215+
from math import inf, nan
216+
216217
from IsoSpecPy.Formulas import *
217218
from scipy.stats import chisquare
218219
import sys

0 commit comments

Comments
 (0)