def setUp(self): states = [(0, 'a', 'b', 1), (0, 'b', 'a', 1), (1, 'b', 'a', 1)] self.fst = Fst(states, ['a', 'b'], ['a', 'b'], 0, 1)
def testInverse(self): """ This function is testing if the inverse is as it should be. """ states = [(0, 'b', 'a', 1), (0, 'a', 'b', 1), (1, 'a', 'b', 1)] inverseFst = Fst(states, ['a', 'b'], ['a', 'b'], 0, 1) realInverseFst = self.fst.inverse() errorMsg = "\nThe inverse of fst:\n" + str(self.fst) + "\n\n" \ "should be like:\n" + str(inverseFst) + "\n\n" \ "but it's like:\n" + str(realInverseFst) self.assertTrue(inverseFst == realInverseFst, msg = errorMsg)
def main(): logging.basicConfig(format='[%(asctime)s]%(levelname)s:%(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO) root_path = os.path.dirname(sys.argv[0]) try: storage = RocksdbStorage(os.path.join(root_path, DATABASE_NAME)) except TypeError: storage = RocksdbStorageV2(os.path.join(root_path, DATABASE_NAME)) deeplab_inst = DeepLab(range(1), root_path, IMG_MEAN, storage) fst_inst = Fst(range(1), root_path, IMG_SHAPE, storage) server = Server(deeplab_inst, fst_inst, root_path, storage) try: server.run() except KeyboardInterrupt: pass finally: deeplab_inst.join_all() fst_inst.join_all() deeplab_inst.shutdown() fst_inst.shutdown()