Ejemplo n.º 1
0
    def test_memory_store_simulate(self):
        store = MemoryStore(2, simulator=sim_multi_out)
        indices = store.sample(100, prior)
        ind_sim = indices[:50]
        store.simulate(ind_sim)

        assert store.sims.x1[49].sum() != 0
        assert store.sims.x1[50].sum() == 0
Ejemplo n.º 2
0
 def test_memory_store_load(self):
     store = MemoryStore(2, simulator=sim_multi_out)
     with tempfile.TemporaryDirectory() as td:
         store.save(td)
         loaded = MemoryStore.load(td)
         loaded.set_simulator(sim_multi_out)
         assert loaded.params == store.params
         assert loaded.zarr_store.root == store.zarr_store.root
         assert loaded._simulator.sim_shapes == sim_multi_out.sim_shapes
Ejemplo n.º 3
0
    def test_init_memory_store_multi_outputs(self):

        store = MemoryStore(2, simulator=sim_multi_out)
        assert len(store.params) == 2
        assert {k: v for k, v in store._simulator.sim_shapes.items()} == {
            "x1": (10,),
            "x2": (2, 5),
        }
Ejemplo n.º 4
0
 def test_memory_store_save(self):
     store = MemoryStore.from_model(model, prior)
     with tempfile.TemporaryDirectory() as td:
         td_path = Path(td)
         store.save(td)
         items = [
             p.relative_to(td).as_posix() for p in td_path.rglob("*") if p.is_dir()
         ]
         assert len(items) > 0
Ejemplo n.º 5
0
 def test_memory_store_sample(self):
     store = MemoryStore.from_model(model, prior)
     indices = store.sample(100, prior)
     assert len(indices) == len(store)
Ejemplo n.º 6
0
 def test_init_memory_store(self):
     store = MemoryStore(2, simulator=sim)
     assert len(store.params) == 2
     assert isinstance(store.zarr_store, zarr.storage.MemoryStore)
     assert isinstance(store._simulator, Simulator)