-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest_interleavedlegacylayer.py
More file actions
46 lines (31 loc) · 1.2 KB
/
test_interleavedlegacylayer.py
File metadata and controls
46 lines (31 loc) · 1.2 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
import unittest
import pathlib
import xmlrunner
from bagPy import *
# define constants used in multiple tests
datapath = str(pathlib.Path(__file__).parent.absolute()) + "/../examples/sample-data"
chunkSize = 100
compressionLevel = 6
class TestInterleavedLegacyLayer(unittest.TestCase):
def testGetLayerAndRead(self):
bagFileName = datapath + "/example_w_qc_layers.bag"
dataset = Dataset.openDataset(bagFileName, BAG_OPEN_READONLY)
self.assertIsNotNone(dataset)
kLayerType = Hypothesis_Strength
layer = dataset.getLayer(kLayerType)
self.assertIsNotNone(layer)
# 2x3
result = layer.read(247, 338, 248, 340)
self.assertIsNotNone(result)
kExpectedNumNodes = 6
buffer = result.asFloatItems()
self.assertEqual(len(buffer), kExpectedNumNodes)
kExpectedBuffer = (1.0e6, 1.0e6, 0.0, 1.0e6, 0.0, 0.0)
for actual, expected in zip(buffer, kExpectedBuffer):
self.assertAlmostEqual(actual, expected, places=5)
del dataset
if __name__ == '__main__':
unittest.main(
testRunner=xmlrunner.XMLTestRunner(output='test-reports'),
failfast=False, buffer=False, catchbreak=False
)