|
1 | 1 | from pyNN.standardmodels import build_translations, StandardModelType, \ |
2 | 2 | STDPWeightDependence, STDPTimingDependence |
3 | 3 | from pyNN.standardmodels.synapses import StaticSynapse, STDPMechanism |
| 4 | +from pyNN.standardmodels.receptors import ( |
| 5 | + CurrExpPostSynapticResponse, |
| 6 | + CondExpPostSynapticResponse, |
| 7 | + CondAlphaPostSynapticResponse, |
| 8 | + CondBetaPostSynapticResponse, |
| 9 | +) |
4 | 10 | from pyNN import errors |
5 | 11 | from pyNN.parameters import ParameterSpace |
6 | 12 | from unittest.mock import Mock |
@@ -216,3 +222,39 @@ def test_STDPMechanism_create_invalid_types(): |
216 | 222 | # test STDPWeightDependence |
217 | 223 |
|
218 | 224 | # test STDPTimingDependence |
| 225 | + |
| 226 | + |
| 227 | +# post-synaptic response models: the validation schema must track each model's |
| 228 | +# default_parameters (see issue #837) |
| 229 | + |
| 230 | +@pytest.mark.parametrize("cls", [ |
| 231 | + CurrExpPostSynapticResponse, |
| 232 | + CondExpPostSynapticResponse, |
| 233 | + CondAlphaPostSynapticResponse, |
| 234 | + CondBetaPostSynapticResponse, |
| 235 | +]) |
| 236 | +def test_psr_schema_matches_default_parameters(cls): |
| 237 | + """The schema used for validation must expose exactly the model's parameters.""" |
| 238 | + assert set(cls().get_schema()) == set(cls.default_parameters) |
| 239 | + |
| 240 | + |
| 241 | +def test_CondBetaPostSynapticResponse_accepts_tau_rise_tau_decay(): |
| 242 | + """Regression test for issue #837: beta receptor must accept its own parameters.""" |
| 243 | + psr = CondBetaPostSynapticResponse(e_syn=0.0, tau_rise=0.2, tau_decay=1.5) |
| 244 | + assert set(psr.get_schema()) == {"locations", "e_syn", "tau_rise", "tau_decay"} |
| 245 | + |
| 246 | + |
| 247 | +def test_CondBetaPostSynapticResponse_rejects_tau_syn(): |
| 248 | + """The beta receptor has no tau_syn parameter, so it must be rejected.""" |
| 249 | + with pytest.raises(errors.NonExistentParameterError): |
| 250 | + CondBetaPostSynapticResponse(tau_syn=5.0) |
| 251 | + |
| 252 | + |
| 253 | +def test_CurrExpPostSynapticResponse_rejects_e_syn(): |
| 254 | + """Current-based response has no reversal potential, so e_syn must be rejected.""" |
| 255 | + with pytest.raises(errors.NonExistentParameterError): |
| 256 | + CurrExpPostSynapticResponse(e_syn=0.0) |
| 257 | + |
| 258 | + |
| 259 | +def test_CurrExpPostSynapticResponse_accepts_tau_syn(): |
| 260 | + CurrExpPostSynapticResponse(tau_syn=5.0) |
0 commit comments