-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_replicate_set_timeline.py
More file actions
62 lines (52 loc) · 2.58 KB
/
Copy pathtest_replicate_set_timeline.py
File metadata and controls
62 lines (52 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import dataclasses
import unittest
import custom_matchers
import helpers
from replicate_set import ReplicateSet
from replicate_set_timeline import ReplicateSetTimeline
class TestReplicateSetTimeline(unittest.TestCase):
rstl1 = ReplicateSetTimeline(
well='A1A2',
replicate_sets=[
ReplicateSet(time=0, data_points={'A1': 0.123, 'A2': 0.345}),
ReplicateSet(time=6, data_points={'A1': 1.123, 'A2': 1.345}),
ReplicateSet(time=12, data_points={'A1': 2.123, 'A2': 2.345})
]
)
def test_plot_data(self):
expected_data = ([0, 6, 12], [
helpers.average_and_apply_beers_law([0.123, 0.345]),
helpers.average_and_apply_beers_law([1.123, 1.345]),
helpers.average_and_apply_beers_law([2.123, 2.345])
])
custom_matchers.assert_arrays_of_arrays_almost_equal(self, self.rstl1.plot_data(), expected_data)
def test_bundle_plot_data(self):
expected_data = ([0, 6, 12], {
'A1': helpers.apply_beers_law([0.123, 1.123, 2.123]),
'A2': helpers.apply_beers_law([0.345, 1.345, 2.345]),
})
custom_matchers.assert_dicts_with_float_arrays_almost_equal(self, self.rstl1.bundle_plot_data()[1],
expected_data[1])
def test_join_replicate_set_timelines(self):
rstl2 = ReplicateSetTimeline(
well='B1B2',
replicate_sets=[
ReplicateSet(time=0, data_points={'B1': 0.678, 'B2': 0.901}),
ReplicateSet(time=6, data_points={'B1': 1.678, 'B2': 1.901}),
ReplicateSet(time=12, data_points={'B1': 2.678, 'B2': 2.901})
]
)
rstl_expected = ReplicateSetTimeline(
well='A1A2B1B2',
replicate_sets=[
ReplicateSet(time=0, data_points={'A1': 0.123, 'A2': 0.345, 'B1': 0.678, 'B2': 0.901}),
ReplicateSet(time=6, data_points={'A1': 1.123, 'A2': 1.345, 'B1': 1.678, 'B2': 1.901}),
ReplicateSet(time=12, data_points={'A1': 2.123, 'A2': 2.345, 'B1': 2.678, 'B2': 2.901})
]
)
custom_matchers.assert_replicate_set_timelines_almost_equal(self, self.rstl1.join(rstl2), rstl_expected)
def test_bundle(self):
self.rstl1.bundle()
custom_matchers.assert_dicts_with_float_arrays_almost_equal(self, self.rstl1.timelines,
{'A1': [0.123, 1.123, 2.123],
'A2': [0.345, 1.345, 2.345]})