def evaluate(string): max_length = 10 max_depth = 6 session_cds = tf.Session() cds = CDS(session_cds, max_length, max_depth) session_cds.run(tf.global_variables_initializer()) expression = string.split() cds.initialize(expression) cds.show() print("Input Expression: {0}".format(expression)) while len(expression) > 1: op_idx = chain_model.apply(session, expression) op = expression[op_idx] try: op_to_apply[op](op_idx, expression, cds) expression = [t[1] for t in cds.current()] except: break return [t[1] for t in cds.current()]
def check_current_joins_three_one_edge_case5(self, next_row): cds = CDS(self.session, 3, 2) self.session.run(tf.global_variables_initializer()) cds.initialize(["l0_c0", "l0_c1", "l0_c2"]) cds.joins([(0, 1)], (next_row, 1), "next") self.assertEqual([((0, 0), "l0_c0"), ((next_row, 1), "next"), ((0, 2), "l0_c2")], cds.current())
def test_current_joins_initialize_three(self): cds = CDS(self.session, 3, 1) self.session.run(tf.global_variables_initializer()) cds.initialize(["l0_c0", "l0_c1", "l0_c2"]) self.assertEqual([((0, 0), "l0_c0"), ((0, 1), "l0_c1"), ((0, 2), "l0_c2")], cds.current())
def check_current_joins_three_three_edges_case1(self, to_column): cds = CDS(self.session, 3, 2) self.session.run(tf.global_variables_initializer()) cds.initialize(["l0_c0", "l0_c1", "l0_c2"]) cds.joins([(0, 0), (0, 1), (0, 2)], (1, to_column), "next") self.assertEqual([((1, to_column), "next")], cds.current())
def test_current_joins_initialize_one(self): cds = CDS(self.session, 1, 1) self.session.run(tf.global_variables_initializer()) cds.initialize(["l0_c0"]) self.assertEqual([((0, 0), "l0_c0")], cds.current())
def test_current_empty(self): cds = CDS(self.session, 1, 1) self.session.run(tf.global_variables_initializer()) self.assertEqual([], cds.current())