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

Commit 7c57ed2

Browse files
committed
Add constraints to synapse property inputs.
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
1 parent 4732fb4 commit 7c57ed2

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

fz_td_recipe/data/schema.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,14 @@ properties:
174174
u_hill_coefficient:
175175
type: number
176176
patternProperties:
177-
"^((decay|depression|facilitation)_time|conductance|u_syn)_(sd|mu)":
177+
"^(decay_time|u_syn)_mu":
178178
type: number
179+
"^(decay_time|u_syn)_sd":
180+
type: number
181+
exclusiveMinimum: 0
182+
"^((depression|facilitation)_time|conductance)_(sd|mu)":
183+
type: number
184+
exclusiveMinimum: 0
179185
rules:
180186
oneOf:
181187
- type: array

tests/test_synapse_property.py

+74-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,89 @@
11
"""Test synapse property mapping"""
22

3+
import json
34
from io import StringIO
45

5-
from fz_td_recipe import XMLRecipe
6+
import pytest
7+
from jsonschema.exceptions import ValidationError
8+
9+
from fz_td_recipe import Recipe, XMLRecipe
610

711

812
def test_synapse_properties():
9-
r = XMLRecipe(StringIO(RECIPE))
13+
r = XMLRecipe(StringIO(RECIPE_XML))
1014
assert set(r.synapse_properties.rules.required) == set(
1115
["fromRegion", "fromHemisphere", "toRegion", "toHemisphere"]
1216
)
1317

1418

15-
RECIPE = """\
19+
def test_valid_synapse_properties(circuit_config, tmp_path, parameter):
20+
data = json.loads(RECIPE_JSON)
21+
22+
recipe_file = tmp_path / "recipe.json"
23+
with recipe_file.open("w") as fd:
24+
json.dump(data, fd)
25+
Recipe(recipe_file, circuit_config, (None, None))
26+
27+
28+
@pytest.mark.parametrize(
29+
"parameter",
30+
[
31+
"decay_time_sd",
32+
"u_syn_sd",
33+
"depression_time_mu",
34+
"depression_time_sd",
35+
"facilitation_time_mu",
36+
"facilitation_time_sd",
37+
"conductance_mu",
38+
"conductance_sd",
39+
],
40+
)
41+
def test_invalid_synapse_properties(circuit_config, tmp_path, parameter):
42+
data = json.loads(RECIPE_JSON)
43+
data["synapse_properties"]["classes"][0][parameter] = 0.0
44+
45+
recipe_file = tmp_path / "recipe.json"
46+
with recipe_file.open("w") as fd:
47+
json.dump(data, fd)
48+
with pytest.raises(ValidationError):
49+
Recipe(recipe_file, circuit_config, (None, None))
50+
51+
52+
RECIPE_JSON = """\
53+
{
54+
"bouton_distances": {},
55+
"gap_junction_properties": {},
56+
"seed": 0,
57+
"synapse_properties": {
58+
"rules": [
59+
{
60+
"src_mtype": "*",
61+
"class": "I1"
62+
}
63+
],
64+
"classes": [
65+
{
66+
"class": "I1",
67+
"n_rrp_vesicles_mu": 1,
68+
"conductance_mu": 0.0,
69+
"conductance_sd": 0.1,
70+
"decay_time_mu": 8.3,
71+
"decay_time_sd": 2.2,
72+
"u_syn_mu": 0.25,
73+
"u_syn_sd": 0.13,
74+
"depression_time_mu": 706.0,
75+
"depression_time_sd": 405.0,
76+
"facilitation_time_mu": 21.0,
77+
"facilitation_time_sd": 9.0
78+
}
79+
]
80+
},
81+
"version": 1
82+
}
83+
"""
84+
85+
86+
RECIPE_XML = """\
1687
<?xml version="1.0"?>
1788
<blueColumn>
1889
<SynapsesProperties>

0 commit comments

Comments
 (0)