Skip to content

Commit

Permalink
fix restrain simdata.placement to chunks in NeuronAdapter (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
filimarc authored Sep 11, 2024
1 parent fc35e97 commit 58a4881
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bsb_neuron/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Chunk,
DatasetNotFoundError,
SimulationData,
SimulationError,
SimulationResult,
SimulatorAdapter,
report,
Expand Down Expand Up @@ -104,6 +105,10 @@ def load_balance(self, simulation):
for chunk in chunks:
simdata.chunk_node_map[chunk] = node
simdata.chunks = simdata.node_chunk_alloc[MPI.get_rank()]
simdata.placement = {
model: model.get_placement_set(chunks=simdata.chunks)
for model in simulation.cell_models.values()
}

def run(self, *simulations: "Simulation"):
unprepared = [sim for sim in simulations if sim not in self.simdata]
Expand Down Expand Up @@ -247,7 +252,10 @@ def __init__(self, model: "NeuronCell", instances: list):
def __getitem__(self, item):
# Boolean masking, kind of
if getattr(item, "dtype", None) == bool or _all_bools(item):
return NeuronPopulation(self._model, [p for p, b in zip(self, item) if b])
if len(self) == len(item):
return NeuronPopulation(self._model, [p for p, b in zip(self, item) if b])
else:
raise SimulationError
elif getattr(item, "dtype", None) == int or _all_ints(item):
if getattr(item, "ndim", None) == 0:
return super().__getitem__(item)
Expand Down

0 comments on commit 58a4881

Please sign in to comment.