def test_vector_constructor(): ctx = Qit() s = Struct(Int(), Int()) v = Vector(s) x = Variable(s, "x") result = ctx.run(v.value([x, s.value((7, 2)), (1, 2)]), args={x: (11,12)}) assert result == [ (11, 12), (7, 2), (1, 2) ]
def test_run_more_values(): ctx = Qit() v = Vector(Int()) a, b, c = ctx.run(Int().value(1), Int().value(2), v.value([1,2,3])) assert a == 1 assert b == 2 assert c == [1,2,3]
def test_vector_values(): ctx = Qit() s1 = [(1, 2), (3, 4), (7, 7)] s2 = [(1, 1), (2, 2)] s3 = [] s4 = [(4, 4), (4, 4), (4, 4)] p = Int() * Int() s = Vector(p) v = s.values(s1, s2, s3, s4) result = ctx.run(v.iterate()) assert result == [s1, s2, s3, s4] result = ctx.run(v.generate().take(150)) assert all(i in [s1, s2, s3, s4] for i in result)
} } return {new_marking}; } return {}; """, is_enabled=fs_enabled[t], t_marking=t_marking, tid=Int().value(t)) for t in range(N_EVENTS)) statespace = ActionSystem(Values(t_marking, [v_marking]), fs_fire) states = statespace.states(DEPTH) f_states = states.iterate().make_function((v_marking, v_input_arcs, v_output_arcs)) init_values = Product((M0, "init_marking"), (Wi, "input"), (Wo, "output")) t_element = statespace.sas_type t_states = Vector(t_element) t_input = init_values.as_type() t_result = Struct((init_values, "init_values"), (t_states, "lts")) f_process_input = Function("map_variables").takes(init_values, "init_values").returns(t_result) f_process_input.code(""" return {{t_result}}(init_values, {{f_states}}(init_values.init_marking, init_values.input, init_values.output)); """, f_states=f_states, t_result=t_result,) f_eq_states = Function("eq_states").takes(t_element, "s1").takes(t_element, "s2").returns(Bool()) f_eq_states.code(""" return s1.s1_id == s2.s1_id && s1.action == s2.action && s1.s2_id == s2.s2_id; """) input_lts = t_states.value([t_element.value((1, "t0", 2)),