|
1 | 1 | """Test synapse property mapping"""
|
2 | 2 |
|
| 3 | +import json |
3 | 4 | from io import StringIO
|
4 | 5 |
|
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 |
6 | 10 |
|
7 | 11 |
|
8 | 12 | def test_synapse_properties():
|
9 |
| - r = XMLRecipe(StringIO(RECIPE)) |
| 13 | + r = XMLRecipe(StringIO(RECIPE_XML)) |
10 | 14 | assert set(r.synapse_properties.rules.required) == set(
|
11 | 15 | ["fromRegion", "fromHemisphere", "toRegion", "toHemisphere"]
|
12 | 16 | )
|
13 | 17 |
|
14 | 18 |
|
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 = """\ |
16 | 87 | <?xml version="1.0"?>
|
17 | 88 | <blueColumn>
|
18 | 89 | <SynapsesProperties>
|
|
0 commit comments