Ejemplo n.º 1
0
    def test_ps(self):
        param = {"p1": 1, "p2": 2}
        ps = self.sim.find_or_create_parameter_set(param)
        self.assertEqual(ps.id(), 0)
        self.assertEqual(ps.v(), param)
        self.assertEqual(ps.runs(), [])
        self.assertEqual(ps.simulator(), self.sim)
        self.assertEqual(ParameterSet.all(), [ps])
        self.assertEqual(ParameterSet.find(0), ps)
        self.assertEqual(self.sim.find_parameter_set(param), ps)
        self.assertEqual(ps.to_dict(), {
            "id": 0,
            "sim_id": 0,
            "params": param,
            "run_ids": []
        })

        # second PS
        param2 = {"p1": 2, "p2": 3}
        ps2 = self.sim.find_or_create_parameter_set(param2)
        self.assertEqual(ps2.id(), 1)
        self.assertEqual(ps2.v(), param2)
        self.assertEqual(ParameterSet.all(), [ps, ps2])

        # duplicate PS
        self.assertEqual(self.sim.find_or_create_parameter_set(param), ps)
        self.assertEqual(len(ParameterSet.all()), 2)
Ejemplo n.º 2
0
 def test_find(self):
     sim2 = Simulator.create("echo")
     self.assertEqual(sim2.id(), 1)
     ps1 = self.sim.find_or_create_parameter_set({"foo": "bar"})
     self.assertEqual(self.sim.parameter_sets(), [ps1])
     ps1.create_runs_upto(2)
     ps2 = sim2.find_or_create_parameter_set({"foo": "bar"})
     self.assertEqual(sim2.parameter_sets(), [ps2])
     ps2.create_runs_upto(2)
     self.assertEqual([r.id() for r in ps1.runs()], [0, 1])
     self.assertEqual([r.id() for r in ps2.runs()], [2, 3])
     self.assertEqual([r.id() for r in ParameterSet.all()], [0, 1])
     self.assertEqual(ParameterSet.find(1), ps2)
Ejemplo n.º 3
0
 def test_find(self):
     ps = ParameterSet.find_or_create(0, 1, 2, 3)
     ps2 = ParameterSet.find_or_create(0, 1, 2, 4)
     pid = ps2.id
     self.assertEqual(pid, 1)
     self.assertEqual(ParameterSet.find(1), ps2)