Skip to content

Commit

Permalink
fix: parallel array placement with offset #889
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed Oct 1, 2024
1 parent 2405b8e commit bc8e9e5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://github.com/dbbs-lab/bsb-core/actions/workflows/build.yml/badge.svg)](https://github.com/dbbs-lab/bsb-core/actions/workflows/build.yml)
[![Build Status](https://github.com/dbbs-lab/bsb-core/actions/workflows/main.yml/badge.svg)](https://github.com/dbbs-lab/bsb-core/actions/workflows/main.yml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Documentation Status](https://readthedocs.org/projects/bsb/badge/?version=latest)](https://bsb.readthedocs.io/en/latest/?badge=latest)
[![codecov](https://codecov.io/gh/dbbs-lab/bsb-core/branch/main/graph/badge.svg)](https://codecov.io/gh/dbbs-lab/bsb-core)
Expand Down
2 changes: 1 addition & 1 deletion bsb/placement/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def place(self, chunk, indicators):
cells[(i * len(x)) : ((i + 1) * len(x)), 1] = y
cells[(i * len(x)) : ((i + 1) * len(x)), 2] = z
# Place all the cells in 1 batch (more efficient)
positions = cells[cells[:, 0] < width - radius]
positions = cells[cells[:, 0] < prt.data.ldc[0] + width - radius]

# Determine in which chunks the cells must be placed
cs = self.scaffold.configuration.network.chunk_size
Expand Down
32 changes: 32 additions & 0 deletions tests/test_placement.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,38 @@ def test_parallel_arrays(self):
self.assertAll(pos[:, 1] <= cfg.partitions.test_layer.data.mdc[1], "not in layer")
self.assertAll(pos[:, 1] >= cfg.partitions.test_layer.data.ldc[1], "not in layer")

def test_regression_issue_889(self):
cfg = Configuration.default(
regions={
"cerebellar_cortex": {"type": "group", "children": ["purkinje_layer"]}
},
partitions={
"purkinje_layer": {
"type": "rhomboid",
"origin": [100, 100, 0],
"dimensions": [100, 100, 15],
}
},
cell_types={
"purkinje_cell": {
"spatial": {"planar_density": 0.00045, "radius": 7.5},
}
},
placement={
"purkinje_layer_placement": {
"strategy": "bsb.placement.ParallelArrayPlacement",
"partitions": ["purkinje_layer"],
"cell_types": ["purkinje_cell"],
"spacing_x": 50,
"angle": 0,
}
},
)
network = Scaffold(cfg, self.storage)
network.compile(clear=True)
ps = network.get_placement_set("purkinje_cell")
self.assertEqual(4, len(ps), "parallel array placement with offset is broken")


class TestVoxelDensities(RandomStorageFixture, unittest.TestCase, engine_name="hdf5"):
def test_particle_vd(self):
Expand Down

0 comments on commit bc8e9e5

Please sign in to comment.