dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

ref in config added to resolved scaffold is not casted. #831

Open drodarie opened 7 months ago

drodarie commented 7 months ago
from bsb import CellType, Configuration, Scaffold

cfg = Configuration.default()
network = Scaffold(config=cfg)

dud_cell = CellType(name="cell_w_count", spatial={"count": 40, "radius": 2})
dud_cell2 = CellType(
        name="cell_rel_count",
        spatial={"relative_to": dud_cell, "count_ratio": 0.5, "radius": 3.4},
    )

network.cell_types["cell_w_count"] = dud_cell
network.cell_types["cell_rel_count"] = dud_cell2

print(network.cell_types["cell_rel_count"].spatial["relative_to"] is None)  # print True 

dud_cell3 = CellType(
        name="cell_rel_count2",
        spatial={"relative_to": "cell_w_count", "count_ratio": 0.5, "radius": 3.4},
    )
network.cell_types["cell_rel_count2"] = dud_cell3
print(network.cell_types["cell_rel_count2"].spatial["relative_to"]) # Works 
Helveg commented 7 months ago

It seems that the bug occurs because of network.cell_types["cell_rel_count"] = dud_cell2 resolving the relative_to reference of dud_cell2 from the object dud_cell to None, while using the string "cell_w_count" is correctly resolved to dud_cell.