Skip to content

Commit 3e89eec

Browse files
committed
🐛 two tests fail
- test 1 - no result obtained at all - test 2 - wrong growth given
1 parent bdee95e commit 3e89eec

File tree

1 file changed

+87
-77
lines changed

1 file changed

+87
-77
lines changed

tests/api_test.py

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -46,83 +46,93 @@ def test_process_curve_time_unit():
4646
assert hours.growth_phases == minutes.growth_phases
4747

4848

49-
def test_process_curve_basic():
50-
with PDFWriter(Path("test.basic.pdf")) as doc:
51-
mu = 0.5
52-
pph = 4.0
53-
curve = pandas.Series(
54-
data=[numpy.exp(mu * i / pph) for i in range(100)],
55-
index=[i / pph for i in range(100)],
56-
)
57-
58-
result = process_curve(curve, constrain_n0=True, n0=0.0)
59-
60-
# self.assertAlmostEqual(mu, slope, 6, msg='growth rate (mu)={}'.format(mu))
61-
62-
doc.write("#0 n0=1", result)
63-
print(result.growth_phases)
64-
assert len(result.growth_phases) == 1
65-
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
66-
assert 0.0 == approx(result.growth_phases[0].n0, 1e-3)
67-
assert result.growth_phases[0].SNR > 1000
68-
69-
result = process_curve(curve, constrain_n0=False)
70-
doc.write("#0 n0=auto", result)
71-
print(result.growth_phases)
72-
assert len(result.growth_phases) == 1
73-
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
74-
assert -0.25 < result.growth_phases[0].n0 < 0.25
75-
assert result.growth_phases[0].SNR > 1000
76-
77-
curve = pandas.Series(
78-
data=(
79-
[1.0] * 5
80-
+ [numpy.exp(mu * i / pph) for i in range(25)]
81-
+ [numpy.exp(mu * 24 / pph)] * 20
82-
),
83-
index=([i / pph for i in range(50)]),
84-
)
85-
86-
result = process_curve(curve, constrain_n0=True, n0=0.0)
87-
doc.write("#1 n0=0", result)
88-
print(result.growth_phases)
89-
assert len(result.growth_phases) == 1
90-
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
91-
assert 0.0 == approx(result.growth_phases[0].n0, 1e-3)
92-
assert result.growth_phases[0].SNR > 1000
93-
94-
result = process_curve(curve, constrain_n0=False)
95-
doc.write("#1 n0=auto", result)
96-
print(result.growth_phases)
97-
assert len(result.growth_phases) == 1
98-
assert mu == approx(result.growth_phases[0].slope, abs=1e-1)
99-
assert -0.25 < result.growth_phases[0].n0 < 0.25
100-
assert result.growth_phases[0].SNR > 1000
101-
102-
mu = 0.20
103-
curve = pandas.Series(
104-
data=(
105-
[i / 10.0 for i in range(10)]
106-
+ [numpy.exp(mu * i / pph) for i in range(25)]
107-
+ [numpy.exp(mu * 24 / pph)] * 15
108-
),
109-
index=([i / pph for i in range(50)]),
110-
)
111-
112-
result = process_curve(curve, constrain_n0=True, n0=0.0)
113-
doc.write("#2 n0=0", result)
114-
print(result.growth_phases)
115-
assert len(result.growth_phases) == 1
116-
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
117-
assert 0.0 == approx(result.growth_phases[0].n0, 1e-6)
118-
assert result.growth_phases[0].SNR > 1000
119-
120-
result = process_curve(curve, constrain_n0=False)
121-
doc.write("#2 n0=auto", result)
122-
assert len(result.growth_phases) == 1
123-
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
124-
assert -0.25 < result.growth_phases[0].n0 < 0.25
125-
assert result.growth_phases[0].SNR > 1000
49+
def test_process_curve_basic0():
50+
# with PDFWriter(Path("test.basic.pdf")) as doc:
51+
mu = 0.5
52+
pph = 4.0
53+
curve = pandas.Series(
54+
data=[numpy.exp(mu * i / pph) for i in range(100)],
55+
index=[i / pph for i in range(100)],
56+
)
57+
58+
result = process_curve(curve, constrain_n0=True, n0=0.0)
59+
60+
# self.assertAlmostEqual(mu, slope, 6, msg="growth rate (mu)={}".format(mu))
61+
62+
# doc.write("#0 n0=1", result)
63+
# print(result.growth_phases)
64+
assert len(result.growth_phases) == 1
65+
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
66+
assert 0.0 == approx(result.growth_phases[0].n0, 1e-3)
67+
assert result.growth_phases[0].SNR > 1000
68+
69+
result = process_curve(curve, constrain_n0=False)
70+
# doc.write("#0 n0=auto", result)
71+
# print(result.growth_phases)
72+
assert len(result.growth_phases) == 1
73+
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
74+
assert -0.25 < result.growth_phases[0].n0 < 0.25
75+
assert result.growth_phases[0].SNR > 1000
76+
77+
78+
def test_process_curve_basic1():
79+
80+
mu = 0.5
81+
pph = 4.0
82+
83+
curve = pandas.Series(
84+
data=(
85+
[1.0] * 5
86+
+ [numpy.exp(mu * i / pph) for i in range(25)]
87+
+ [numpy.exp(mu * 24 / pph)] * 20
88+
),
89+
index=([i / pph for i in range(50)]),
90+
)
91+
92+
result = process_curve(curve, constrain_n0=True, n0=0.0)
93+
# doc.write("#1 n0=0", result)
94+
# print(result.growth_phases)
95+
assert len(result.growth_phases) == 1
96+
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
97+
assert 0.0 == approx(result.growth_phases[0].n0, 1e-3)
98+
assert result.growth_phases[0].SNR > 1000
99+
100+
result = process_curve(curve, constrain_n0=False)
101+
# doc.write("#1 n0=auto", result)
102+
# print(result.growth_phases)
103+
assert len(result.growth_phases) == 1
104+
assert mu == approx(result.growth_phases[0].slope, abs=1e-1)
105+
assert -0.25 < result.growth_phases[0].n0 < 0.25
106+
assert result.growth_phases[0].SNR > 1000
107+
108+
109+
def test_process_curve_basic2():
110+
mu = 0.20
111+
pph = 4.0
112+
113+
curve = pandas.Series(
114+
data=(
115+
[i / 10.0 for i in range(10)]
116+
+ [numpy.exp(mu * i / pph) for i in range(25)]
117+
+ [numpy.exp(mu * 24 / pph)] * 15
118+
),
119+
index=([i / pph for i in range(50)]),
120+
)
121+
122+
result = process_curve(curve, constrain_n0=True, n0=0.0)
123+
# doc.write("#2 n0=0", result)
124+
# print(result.growth_phases)
125+
assert len(result.growth_phases) == 1
126+
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
127+
assert 0.0 == approx(result.growth_phases[0].n0, 1e-6)
128+
assert result.growth_phases[0].SNR > 1000
129+
130+
result = process_curve(curve, constrain_n0=False)
131+
# doc.write("#2 n0=auto", result)
132+
assert len(result.growth_phases) == 1
133+
assert mu == approx(result.growth_phases[0].slope, abs=1e-2)
134+
assert -0.25 < result.growth_phases[0].n0 < 0.25
135+
assert result.growth_phases[0].SNR > 1000
126136

127137

128138
def test_process_curve_wrong_time_unit():

0 commit comments

Comments
 (0)