Skip to content

Commit

Permalink
Improve logging when constraits are invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
frthjf committed Oct 20, 2023
1 parent 2e5f564 commit c873b4c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/miv_simulator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,46 @@ def _cast(v) -> int:
"""One of the layers defined in the LayersDef enum."""

CellDistribution = Dict[LayerName, int]
"""For a given neuron kind, this defines the distribution (i.e. numbers) of neurons accross the different layers."""
"""For a given neuron kind, this defines the distribution (i.e. numbers) of neurons accross the different layers.
Example:
```python
{
"STIM": {"SO": 0, "SP": 64, "SR": 0, "SLM": 0},
"PYR": {"SO": 0, "SP": 223, "SR": 0, "SLM": 0},
"PVBC": {"SO": 35, "SP": 50, "SR": 8, "SLM": 0},
"OLM": {"SO": 21, "SP": 0, "SR": 0, "SLM": 0},
}
```
"""

LayerExtents = Dict[LayerName, List[ParametricCoordinate]]
"""Describes a volume extent"""
"""Describes a volume extent
Example:
```python
{
"SO": [[0.0, 0.0, 0.0], [200.0, 200.0, 5.0]],
"SP": [[0.0, 0.0, 5.0], [200.0, 200.0, 50.0]],
"SR": [[0.0, 0.0, 50.0], [200.0, 200.0, 100.0]],
"SLM": [[0.0, 0.0, 100.0], [200.0, 200.0, 150.0]],
}
```
"""

CellConstraints = Optional[
Dict[PopulationName, Dict[LayerName, Tuple[float, float]]]
]
"""Describes constraints on the distribution of neurons in a given layer."""
"""Describes constraints on the distribution of neurons in a given layer.
Example:
```python
{
"PC": {"SP": [100, 120]},
"PVBC": {"SR": [150, 200]},
}
```
"""


# Pydantic data models
Expand Down
12 changes: 12 additions & 0 deletions src/miv_simulator/simulator/generate_network_architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def rho(x):
)
)
]
if len(nodes) != len(nodes1):
logger.info(
f"{len(nodes) - len(nodes1)} nodes out of {len(nodes)} were NaN"
)

# remove nodes outside of the domain
vert, smp = domain
Expand All @@ -113,6 +117,14 @@ def rho(x):
and current_xyz[i][2] <= constraint[1]
):
valid_idxs.append(i)
if len(valid_idxs) == 0:
logger.info(
f"Warning: all in_nodes have been rejected due to constraint {constraint}!"
)
elif len(valid_idxs) != len(in_nodes):
logger.info(
f"Removing {len(in_nodes)-len(valid_idxs)} out of {len(in_nodes)} nodes due to constraint {constraint}"
)
in_nodes = in_nodes[valid_idxs]
node_count = len(in_nodes)
N = int(1.5 * N)
Expand Down

0 comments on commit c873b4c

Please sign in to comment.