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__)