Beispiel #1
0
def test_serialize():
    """ephys.locations: Test serialize functionality"""
    from bluepyopt.ephys.locations import (
        NrnSeclistCompLocation,
        NrnSeclistLocation,
        NrnSeclistSecLocation,
        NrnSomaDistanceCompLocation)

    seclist_name, sec_index, comp_x, soma_distance = 'somatic', 0, 0.5, 800
    locations = (
        NrnSeclistCompLocation('NrnSeclistCompLocation',
                               seclist_name, sec_index, comp_x),
        NrnSeclistLocation(
            'NrnSeclistLocation', seclist_name),
        NrnSeclistSecLocation(
            'NrnSeclistSecLocation', seclist_name, sec_index),
        NrnSomaDistanceCompLocation(
            'NrnSomaDistanceCompLocation', soma_distance, seclist_name),)

    for loc in locations:
        serialized = loc.to_dict()
        assert isinstance(json.dumps(serialized), str)
        deserialized = instantiator(serialized)
        assert isinstance(deserialized, loc.__class__)
        assert deserialized.seclist_name == seclist_name
        assert deserialized.name == loc.__class__.__name__
Beispiel #2
0
def test_mechanism_serialize():
    """ephys.mechanisms: Testing serialize"""
    mech = utils.make_mech()
    serialized = mech.to_dict()
    nt.ok_(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, ephys.mechanisms.NrnMODMechanism))
Beispiel #3
0
def test_mechanism_serialize():
    """ephys.mechanisms: Testing serialize"""
    mech = utils.make_mech()
    serialized = mech.to_dict()
    nt.assert_true(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.assert_true(isinstance(deserialized, ephys.mechanisms.NrnMODMechanism))
Beispiel #4
0
def test_serialize():
    """ephys.locations: Test serialize functionality"""
    from bluepyopt.ephys.locations import (
        NrnSeclistCompLocation,
        NrnSeclistLocation,
        NrnSeclistSecLocation,
        NrnSomaDistanceCompLocation)

    seclist_name, sec_index, comp_x, soma_distance = 'somatic', 0, 0.5, 800
    locations = (
        NrnSeclistCompLocation('NrnSeclistCompLocation',
                               seclist_name, sec_index, comp_x),
        NrnSeclistLocation(
            'NrnSeclistLocation', seclist_name),
        NrnSeclistSecLocation(
            'NrnSeclistSecLocation', seclist_name, sec_index),
        NrnSomaDistanceCompLocation(
            'NrnSomaDistanceCompLocation', soma_distance, seclist_name),)

    for loc in locations:
        serialized = loc.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, loc.__class__))
        nt.eq_(deserialized.seclist_name, seclist_name)
        nt.eq_(deserialized.name, loc.__class__.__name__)
Beispiel #5
0
def test_serialize():
    """ephys.locations: Test serialize functionality"""
    from bluepyopt.ephys.locations import (
        NrnSeclistCompLocation,
        NrnSeclistLocation,
        NrnSeclistSecLocation,
        NrnSomaDistanceCompLocation,
    )

    seclist_name, sec_index, comp_x, soma_distance = "somatic", 0, 0.5, 800
    locations = (
        NrnSeclistCompLocation("NrnSeclistCompLocation", seclist_name,
                               sec_index, comp_x),
        NrnSeclistLocation("NrnSeclistLocation", seclist_name),
        NrnSeclistSecLocation("NrnSeclistSecLocation", seclist_name,
                              sec_index),
        NrnSomaDistanceCompLocation("NrnSomaDistanceCompLocation",
                                    soma_distance, seclist_name),
    )

    for loc in locations:
        serialized = loc.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, loc.__class__))
        nt.eq_(deserialized.seclist_name, seclist_name)
        nt.eq_(deserialized.name, loc.__class__.__name__)
def test_mechanism_serialize():
    basal = ephys.locations.NrnSeclistLocation('basal', seclist_name='basal')
    apical = ephys.locations.NrnSeclistLocation('apical', seclist_name='apical')
    mech = ephys.mechanisms.NrnMODMechanism('Ih', prefix='Ih', locations=[basal, apical, ])
    serialized = mech.to_dict()
    nt.ok_(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, ephys.mechanisms.NrnMODMechanism))
def test_serialize():
    """ephys.morphology: testing serialization"""

    morph = ephys.morphologies.NrnFileMorphology(simpleswc_morphpath)
    serialized = morph.to_dict()
    nt.ok_(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, ephys.morphologies.NrnFileMorphology))
    nt.eq_(deserialized.morphology_path, simpleswc_morphpath)
Beispiel #8
0
def test_serialize():
    """ephys.morphology: testing serialization"""

    morph = ephys.morphologies.NrnFileMorphology(simpleswc_morphpath)
    serialized = morph.to_dict()
    nt.ok_(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, ephys.morphologies.NrnFileMorphology))
    nt.eq_(deserialized.morphology_path, simpleswc_morphpath)
Beispiel #9
0
def test_serialize():
    parameters = utils.make_parameters()

    for param in parameters:
        serialized = param.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, param.__class__))
        nt.eq_(deserialized.name, param.__class__.__name__)
Beispiel #10
0
def test_serialize():
    """ephys.parameters: Test serialize"""
    parameters = utils.make_parameters()

    for param in parameters:
        serialized = param.to_dict()
        assert isinstance(json.dumps(serialized), str)
        deserialized = instantiator(serialized)
        assert isinstance(deserialized, param.__class__)
        assert deserialized.name == param.__class__.__name__
Beispiel #11
0
def test_serialize():

    multiplier, offset, distribution = 12.12, 3.58, '1 + {distance}'
    paramscalers = (
        NrnSegmentLinearScaler('NrnSegmentLinearScaler', multiplier, offset),
        NrnSegmentSomaDistanceScaler('NrnSegmentSomaDistanceScaler', distribution),)

    for ps in paramscalers:
        serialized = ps.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, ps.__class__))
        nt.eq_(deserialized.name, ps.__class__.__name__)
Beispiel #12
0
def test_mechanism_serialize():
    basal = ephys.locations.NrnSeclistLocation('basal', seclist_name='basal')
    apical = ephys.locations.NrnSeclistLocation('apical',
                                                seclist_name='apical')
    mech = ephys.mechanisms.NrnMODMechanism('Ih',
                                            prefix='Ih',
                                            locations=[
                                                basal,
                                                apical,
                                            ])
    serialized = mech.to_dict()
    nt.ok_(isinstance(json.dumps(serialized), str))
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, ephys.mechanisms.NrnMODMechanism))
Beispiel #13
0
def test_eFELFeature_serialize():
    recording_names = {'': 'square_pulse_step1.soma.v'}
    efeature = efeatures.eFELFeature(name='test_eFELFeature',
                                     efel_feature_name='voltage_base',
                                     recording_names=recording_names,
                                     stim_start=700,
                                     stim_end=2700,
                                     exp_mean=1,
                                     exp_std=1)
    serialized = efeature.to_dict()
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, efeatures.eFELFeature))
    nt.eq_(deserialized.stim_start, 700)
    nt.eq_(deserialized.recording_names, recording_names)
Beispiel #14
0
def test_eFELFeature_serialize():
    recording_names = {'': 'square_pulse_step1.soma.v'}
    efeature = efeatures.eFELFeature(name='test_eFELFeature',
                                     efel_feature_name='voltage_base',
                                     recording_names=recording_names,
                                     stim_start=700,
                                     stim_end=2700,
                                     exp_mean=1,
                                     exp_std=1)
    serialized = efeature.to_dict()
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, efeatures.eFELFeature))
    nt.eq_(deserialized.stim_start, 700)
    nt.eq_(deserialized.recording_names, recording_names)
Beispiel #15
0
def test_eFELFeature_serialize():
    """ephys.efeatures: Testing eFELFeature serialization"""
    recording_names = {'': 'square_pulse_step1.soma.v'}
    efeature = efeatures.eFELFeature(name='test_eFELFeature',
                                     efel_feature_name='voltage_base',
                                     recording_names=recording_names,
                                     stim_start=700,
                                     stim_end=2700,
                                     exp_mean=1,
                                     exp_std=1)
    serialized = efeature.to_dict()
    deserialized = instantiator(serialized)
    assert isinstance(deserialized, efeatures.eFELFeature)
    assert deserialized.stim_start == 700
    assert deserialized.recording_names == recording_names
Beispiel #16
0
def test_eFELFeature_serialize():
    """ephys.efeatures: Testing eFELFeature serialization"""
    recording_names = {"": "square_pulse_step1.soma.v"}
    efeature = efeatures.eFELFeature(
        name="test_eFELFeature",
        efel_feature_name="voltage_base",
        recording_names=recording_names,
        stim_start=700,
        stim_end=2700,
        exp_mean=1,
        exp_std=1,
    )
    serialized = efeature.to_dict()
    deserialized = instantiator(serialized)
    nt.ok_(isinstance(deserialized, efeatures.eFELFeature))
    nt.eq_(deserialized.stim_start, 700)
    nt.eq_(deserialized.recording_names, recording_names)
Beispiel #17
0
def test_serialize():
    """ephys.parameterscalers: test serialization"""

    multiplier, offset, distribution = 12.12, 3.58, '1 + {distance}'
    paramscalers = (
        NrnSegmentLinearScaler(
            'NrnSegmentLinearScaler',
            multiplier,
            offset),
        NrnSegmentSomaDistanceScaler(
            'NrnSegmentSomaDistanceScaler',
            distribution),
    )

    for ps in paramscalers:
        serialized = ps.to_dict()
        assert isinstance(json.dumps(serialized), str)
        deserialized = instantiator(serialized)
        assert isinstance(deserialized, ps.__class__)
        assert deserialized.name == ps.__class__.__name__
Beispiel #18
0
def test_serialize():
    value, frozen, bounds, param_name = 65, False, [0, 100.0], 'gSKv3_1bar_SKv3_1'
    value_scaler = ephys.parameterscalers.NrnSegmentLinearScaler()
    locations = (NrnSeclistLocation('Location0', 'somatic'),
                 NrnSeclistLocation('Location1', 'apical'),
                 )

    parameters = (
        NrnGlobalParameter('NrnGlobalParameter', value, frozen, bounds, param_name),
        NrnSectionParameter(
            'NrnSectionParameter', value, frozen, bounds, param_name, value_scaler, locations ),
        NrnRangeParameter(
            'NrnRangeParameter', value, frozen, bounds, param_name, value_scaler, locations),
    )

    for param in parameters:
        serialized = param.to_dict()
        nt.ok_(isinstance(json.dumps(serialized), str))
        deserialized = instantiator(serialized)
        nt.ok_(isinstance(deserialized, param.__class__))
        nt.eq_(deserialized.name, param.__class__.__name__)