Esempio n. 1
0
 def test_tol_methods(self):
     tol = 1e-3
     val = 1e-4
     self.assertTrue(util.eq(val, 0, tol))
     self.assertTrue(util.le(val, 0, tol))
     self.assertFalse(util.lt(val, 0, tol))
     val = -1e-4
     self.assertTrue(util.eq(val, 0, tol))
     self.assertTrue(util.le(val, 0, tol))
     self.assertFalse(util.lt(val, 0, tol))
Esempio n. 2
0
def getBlocks(fname):
    blocks = []
    with open(fname, "rb") as f:
        data = f.read()
        ptr = 0
        while ptr < len(data):
            begin = ptr
            bid = data[ptr]
            ptr += 1
            if bid == BlockType.glue:
                ptr += 9
            elif bid == BlockType.info:
                ptr += le(data[ptr + 0x10:ptr + 0x14]) + 0x14
            elif bid == BlockType.directRecording:
                ptr += le(data[ptr + 5:ptr + 8]) + 8
            else:
                raise Exception(f"Unknow block {bid:02x}")
            blocks.append(data[begin:ptr])
    return blocks