Skip to content

Commit

Permalink
don't enforce having cao_CR_GluSynapse when extracellular_calcium is set
Browse files Browse the repository at this point in the history
  • Loading branch information
anilbey committed Sep 26, 2023
1 parent 9ea6f94 commit c5180bd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ nrnivmodl.log
.mypy_cache
.ruff_cache
.pytest_cache
*.btr
7 changes: 5 additions & 2 deletions bluecellulab/simulation/neuron_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@


def set_global_condition_parameters(condition_parameters: Conditions) -> None:
"""Sets the global condition parameters in NEURON objects."""
if condition_parameters.extracellular_calcium is not None:
"""Sets the global condition parameters in NEURON objects if GluSynapse is
available."""
if condition_parameters.extracellular_calcium is not None and hasattr(
bluecellulab.neuron.h, "cao_CR_GluSynapse"
):
cao_cr_glusynapse = condition_parameters.extracellular_calcium
with error_context("mechanism/s for cao_CR_GluSynapse need to be compiled"):
bluecellulab.neuron.h.cao_CR_GluSynapse = cao_cr_glusynapse
Expand Down
54 changes: 54 additions & 0 deletions tests/test_simulation/test_neuron_globals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from unittest import mock
import pytest
import bluecellulab
from bluecellulab.circuit.config.sections import ConditionEntry, Conditions, MechanismConditions
from bluecellulab.simulation.neuron_globals import set_global_condition_parameters, set_init_depleted_values, set_minis_single_vesicle_values, set_tstop_value


def test_set_tstop_value():
set_tstop_value(100.0)
assert bluecellulab.neuron.h.tstop == 100.0


@mock.patch("bluecellulab.neuron.h")
def test_set_global_condition_parameters_no_mechs(mocked_h):
del mocked_h.cao_CR_GluSynapse # delete the attribute for the mock
calcium_condition = Conditions(extracellular_calcium=2.0)
set_global_condition_parameters(calcium_condition)
assert not hasattr(bluecellulab.neuron.h, "cao_CR_GluSynapse")

mech_conditions = Conditions(mech_conditions=MechanismConditions(None, None, None))
set_global_condition_parameters(mech_conditions)


@pytest.mark.v6
def test_set_global_condition_parameters():
calcium_condition = Conditions(extracellular_calcium=2.015)
set_global_condition_parameters(calcium_condition)
assert bluecellulab.neuron.h.cao_CR_GluSynapse == 2.015


@pytest.mark.v6
def test_set_init_depleted_values():
mech_conditions = MechanismConditions(
ampanmda=ConditionEntry(minis_single_vesicle=None, init_depleted=True),
gabaab=ConditionEntry(minis_single_vesicle=None, init_depleted=False),
glusynapse=ConditionEntry(minis_single_vesicle=None, init_depleted=None),
)
set_init_depleted_values(mech_conditions)
assert bluecellulab.neuron.h.init_depleted_ProbAMPANMDA_EMS == 1.0
assert bluecellulab.neuron.h.init_depleted_ProbGABAAB_EMS == 0.0
assert bluecellulab.neuron.h.init_depleted_GluSynapse == 0.0


@pytest.mark.v6
def test_set_minis_single_vesicle_values():
mech_conditions = MechanismConditions(
ampanmda=ConditionEntry(minis_single_vesicle=True, init_depleted=None),
gabaab=ConditionEntry(minis_single_vesicle=False, init_depleted=None),
glusynapse=ConditionEntry(minis_single_vesicle=None, init_depleted=None),
)
set_minis_single_vesicle_values(mech_conditions)
assert bluecellulab.neuron.h.minis_single_vesicle_ProbAMPANMDA_EMS == 1.0
assert bluecellulab.neuron.h.minis_single_vesicle_ProbGABAAB_EMS == 0.0
assert bluecellulab.neuron.h.minis_single_vesicle_GluSynapse == 0.0

0 comments on commit c5180bd

Please sign in to comment.