- Timestamp:
- 07/26/11 16:21:50 (10 months ago)
- Files:
-
- 1 modified
-
trunk/src/nest/nineml.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/nest/nineml.py
r983 r987 20 20 from __future__ import absolute_import # Not compatible with Python 2.4 21 21 import subprocess 22 import neuron22 #import neuron 23 23 from pyNN.models import BaseCellType 24 24 #from pyNN.nineml.cells import _build_nineml_celltype … … 66 66 def __new__(cls, name, bases, dct): 67 67 68 import nineml.abstraction_layer as nineml69 from nineml.abstraction_layer import models68 import nineml.abstraction_layer as al 69 from nineml.abstraction_layer import flattening, writers, component_modifiers 70 70 import nest 71 71 72 72 #Extract Parameters Back out from Dict: 73 73 nineml_model = dct['nineml_model'] 74 74 synapse_components = dct['synapse_components'] 75 75 76 # Reduce the model: 77 reduced_component = models.reduce_to_single_component( nineml_model, 78 componentname=name ) 79 reduced_component.backsub_all() 80 #reduced_component.backsub_aliases() 81 #reduced_component.backsub_equations() 76 # Flatten the model: 77 assert isinstance(nineml_model, al.ComponentClass) 78 if nineml_model.is_flat(): 79 flat_component = nineml_model 80 else: 81 flat_component = flattening.flatten( nineml_model,name ) 82 83 # Make the substitutions: 84 flat_component.backsub_all() 85 #flat_component.backsub_aliases() 86 #flat_component.backsub_equations() 82 87 83 reduced_component.short_description = "Auto-generated 9ML neuron model for PyNN.nest" 84 reduced_component.long_description = "Auto-generated 9ML neuron model for PyNN.nest" 88 # Close any open reduce ports: 89 component_modifiers.ComponentModifier.close_all_reduce_ports(component = flat_component) 90 91 92 flat_component.short_description = "Auto-generated 9ML neuron model for PyNN.nest" 93 flat_component.long_description = "Auto-generated 9ML neuron model for PyNN.nest" 94 95 # Close any open reduce ports: 96 component_modifiers.ComponentModifier.close_all_reduce_ports(component = flat_component) 85 97 86 98 # synapse ports: … … 91 103 #syn_component = nineml_model[syn.namespace] 92 104 syn_component = nineml_model.subnodes[syn.namespace] 93 recv_event_ports = list(syn_component. filter_ports(cls=nineml.EventPort, mode='recv'))105 recv_event_ports = list(syn_component.query.event_recv_ports) 94 106 # check there's only one 95 107 if len(recv_event_ports)!=1: 96 108 raise ValueError, "A synapse component has multiple recv ports. Cannot dis-ambiguate" 97 synapse_ports.append(syn.namespace+'_'+recv_event_ports[0]. symbol)109 synapse_ports.append(syn.namespace+'_'+recv_event_ports[0].name) 98 110 99 111 100 112 # New: 101 dct["combined_model"] = reduced_component113 dct["combined_model"] = flat_component 102 114 # TODO: Override this with user layer 103 115 #default_values = ModelToSingleComponentReducer.flatten_namespace_dict( parameters ) 104 dct["default_parameters"] = dict( ( name, 1.0) for name in reduced_component.parameters )105 dct["default_initial_values"] = dict(( name, 0.0) for name in reduced_component.state_variables)116 dct["default_parameters"] = dict( (p.name, 1.0) for p in flat_component.parameters ) 117 dct["default_initial_values"] = dict((s.name, 0.0) for s in flat_component.state_variables) 106 118 dct["synapse_types"] = [syn.namespace for syn in synapse_components] 107 119 dct["standard_receptor_type"] = (dct["synapse_types"] == ('excitatory', 'inhibitory')) … … 113 125 114 126 # Recording from bindings: 115 dct["recordable"] = [port.name for port in reduced_component.analog_ports] + ['spikes', 'regime']127 dct["recordable"] = [port.name for port in flat_component.analog_ports] + ['spikes', 'regime'] 116 128 # TODO bindings -> alias and support recording of them in nest template 117 #+ [binding.name for binding in reduced_component.bindings]129 #+ [binding.name for binding in flat_component.bindings] 118 130 119 131 dct["weight_variables"] = dict([ (syn.namespace,syn.namespace+'_'+syn.weight_connector ) … … 123 135 124 136 # TODO: UL configuration of initial regime. 125 initial_regime = reduced_component.regime_map.keys()[0]137 initial_regime = flat_component.regimes_map.keys()[0] 126 138 127 139 from nestbuilder import NestFileBuilder 128 140 nfb = NestFileBuilder( nest_classname = name, 129 component = reduced_component,141 component = flat_component, 130 142 synapse_ports = synapse_ports, 131 143 initial_regime = initial_regime,
