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__
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 make_parameters(): 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), ) return parameters
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__)
def make_parameters(): """Create parameters""" 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, ), ) return parameters