Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit

Permalink
Add constraints to synapse property inputs. (#10)
Browse files Browse the repository at this point in the history
Having these values be zero or smaller will lead to non-sensical
probability distribution inputs, either for the standard deviation of
all distributions, or for the scale of the gamma distribution.

Fixes #9
  • Loading branch information
matz-e authored Sep 25, 2024
1 parent 4732fb4 commit 32e1567
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
8 changes: 7 additions & 1 deletion fz_td_recipe/data/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@ properties:
u_hill_coefficient:
type: number
patternProperties:
"^((decay|depression|facilitation)_time|conductance|u_syn)_(sd|mu)":
"^(decay_time|u_syn)_mu":
type: number
"^(decay_time|u_syn)_sd":
type: number
exclusiveMinimum: 0
"^((depression|facilitation)_time|conductance)_(sd|mu)":
type: number
exclusiveMinimum: 0
rules:
oneOf:
- type: array
Expand Down
77 changes: 74 additions & 3 deletions tests/test_synapse_property.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,89 @@
"""Test synapse property mapping"""

import json
from io import StringIO

from fz_td_recipe import XMLRecipe
import pytest
from jsonschema.exceptions import ValidationError

from fz_td_recipe import Recipe, XMLRecipe


def test_synapse_properties():
r = XMLRecipe(StringIO(RECIPE))
r = XMLRecipe(StringIO(RECIPE_XML))
assert set(r.synapse_properties.rules.required) == set(
["fromRegion", "fromHemisphere", "toRegion", "toHemisphere"]
)


RECIPE = """\
def test_valid_synapse_properties(circuit_config, tmp_path):
data = json.loads(RECIPE_JSON)

recipe_file = tmp_path / "recipe.json"
with recipe_file.open("w") as fd:
json.dump(data, fd)
Recipe(recipe_file, circuit_config, (None, None))


@pytest.mark.parametrize(
"parameter",
[
"decay_time_sd",
"u_syn_sd",
"depression_time_mu",
"depression_time_sd",
"facilitation_time_mu",
"facilitation_time_sd",
"conductance_mu",
"conductance_sd",
],
)
def test_invalid_synapse_properties(circuit_config, tmp_path, parameter):
data = json.loads(RECIPE_JSON)
data["synapse_properties"]["classes"][0][parameter] = 0.0

recipe_file = tmp_path / "recipe.json"
with recipe_file.open("w") as fd:
json.dump(data, fd)
with pytest.raises(ValidationError, match=parameter):
Recipe(recipe_file, circuit_config, (None, None))


RECIPE_JSON = """\
{
"bouton_distances": {},
"gap_junction_properties": {},
"seed": 0,
"synapse_properties": {
"rules": [
{
"src_mtype": "*",
"class": "I1"
}
],
"classes": [
{
"class": "I1",
"n_rrp_vesicles_mu": 1,
"conductance_mu": 1.0,
"conductance_sd": 0.1,
"decay_time_mu": 8.3,
"decay_time_sd": 2.2,
"u_syn_mu": 0.25,
"u_syn_sd": 0.13,
"depression_time_mu": 706.0,
"depression_time_sd": 405.0,
"facilitation_time_mu": 21.0,
"facilitation_time_sd": 9.0
}
]
},
"version": 1
}
"""


RECIPE_XML = """\
<?xml version="1.0"?>
<blueColumn>
<SynapsesProperties>
Expand Down

0 comments on commit 32e1567

Please sign in to comment.