Changeset 708 for trunk/src/neuroml.py
- Timestamp:
- 02/12/10 16:02:09 (2 years ago)
- Files:
-
- 1 modified
-
trunk/src/neuroml.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/neuroml.py
r705 r708 7 7 from pyNN import common, connectors, cells 8 8 import math 9 #import numpy, types, sys, shutil 9 import numpy 10 10 import sys 11 11 sys.path.append('/usr/lib/python%s/site-packages/oldxml' % sys.version[:3]) # needed for Ubuntu … … 24 24 neuroml_xsd="http://www.neuroml.org/NeuroMLValidator/NeuroMLFiles/Schemata/v"+neuroml_ver+"/Level3/NeuroML_Level3_v"+neuroml_ver+".xsd" 25 25 26 strict = False 27 26 28 # ============================================================================== 27 29 # Utility classes 28 30 # ============================================================================== 29 31 30 class ID( common.IDMixin):32 class ID(int, common.IDMixin): 31 33 """ 32 34 Instead of storing ids as integers, we store them as ID objects, … … 38 40 39 41 def __init__(self, n): 40 common.IDMixin.__init__(self , n)42 common.IDMixin.__init__(self) 41 43 42 44 # ============================================================================== … … 179 181 return cell_node, channel_nodes, synapse_nodes 180 182 183 184 class NotImplementedModel(object): 185 186 def __init__(self): 187 if strict: 188 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 189 190 def build_nodes(self): 191 cell_node = build_node(':not_implemented_cell', name=self.label) 192 doc_node = build_node('meta:notes', "PyNN %s cell type not implemented" % self.__class__.__name__) 193 return cell_node, [], [] 194 195 181 196 # ============================================================================== 182 197 # Standard cells 183 198 # ============================================================================== 184 199 185 class IF_curr_exp(cells.IF_curr_exp ):200 class IF_curr_exp(cells.IF_curr_exp, NotImplementedModel): 186 201 """Leaky integrate and fire model with fixed threshold and 187 202 decaying-exponential post-synaptic current. (Separate synaptic currents for 188 203 excitatory and inhibitory synapses""" 189 204 205 n = 0 206 translations = common.build_translations(*[(name, name) 207 for name in cells.IF_curr_exp.default_parameters]) 208 190 209 def __init__(self, parameters): 191 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 192 193 class IF_curr_alpha(cells.IF_curr_alpha): 210 NotImplementedModel.__init__(self) 211 cells.IF_curr_exp.__init__(self, parameters) 212 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 213 self.synapse_type = "doub_exp_syn" 214 self.__class__.n += 1 215 216 class IF_curr_alpha(cells.IF_curr_alpha, NotImplementedModel): 194 217 """Leaky integrate and fire model with fixed threshold and alpha-function- 195 218 shaped post-synaptic current.""" 196 219 220 n = 0 221 translations = common.build_translations(*[(name, name) 222 for name in cells.IF_curr_alpha.default_parameters]) 223 197 224 def __init__(self, parameters): 198 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 225 NotImplementedModel.__init__(self) 226 cells.IF_curr_exp.__init__(self, parameters) 227 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 228 self.synapse_type = "doub_exp_syn" 229 self.__class__.n += 1 199 230 200 231 class IF_cond_exp(cells.IF_cond_exp, IF_base): … … 226 257 self.__class__.n += 1 227 258 228 class SpikeSourcePoisson(cells.SpikeSourcePoisson ):259 class SpikeSourcePoisson(cells.SpikeSourcePoisson, NotImplementedModel): 229 260 """Spike source, generating spikes according to a Poisson process.""" 230 261 262 n = 0 263 translations = common.build_translations(*[(name, name) 264 for name in cells.SpikeSourcePoisson.default_parameters]) 265 231 266 def __init__(self, parameters): 232 raise Exception('Cell type %s not yet implemented' % self.__class__.__name__)267 NotImplementedModel.__init__(self) 233 268 cells.SpikeSourcePoisson.__init__(self, parameters) 234 235 236 class SpikeSourceArray(cells.SpikeSourceArray): 269 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 270 self.__class__.n += 1 271 272 273 class SpikeSourceArray(cells.SpikeSourceArray, NotImplementedModel): 237 274 """Spike source generating spikes at the times given in the spike_times array.""" 238 275 276 n = 0 277 translations = common.build_translations(*[(name, name) 278 for name in cells.SpikeSourcePoisson.default_parameters]) 279 239 280 def __init__(self, parameters): 240 raise Exception('Cell type %s not yet implemented' % self.__class__.__name__) 241 cells.SpikeSourceArray.__init__(self, parameters) 281 NotImplementedModel.__init__(self) 282 cells.SpikeSourceARRAY.__init__(self, parameters) 283 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 284 self.__class__.n += 1 242 285 243 286 … … 253 296 simulator but not by others. 254 297 """ 255 global xmldoc, xmlfile, populations_node, projections_node, inputs_node, cells_node, channels_node, neuromlNode 298 global xmldoc, xmlfile, populations_node, projections_node, inputs_node, cells_node, channels_node, neuromlNode, strict 256 299 xmlfile = extra_params['file'] 257 300 if isinstance(xmlfile, basestring): 258 301 xmlfile = open(xmlfile, 'w') 302 if 'strict' in extra_params: 303 strict = extra_params['strict'] 259 304 dt = timestep 260 305 xmldoc = xml.dom.minidom.Document() … … 296 341 def num_processes(): 297 342 return 1 343 common.num_processes = num_processes 344 345 def rank(): 346 return 0 347 common.rank = rank 298 348 299 349 … … 388 438 channels_node.appendChild(synapse_node) 389 439 440 self.first_id = 0 441 self.last_id = self.size-1 442 self.all_cells = numpy.array([ID(id) for id in range(self.first_id, self.last_id+1)], dtype=ID).reshape(dims) 443 self._mask_local = numpy.ones_like(self.all_cells).astype(bool) 444 self.local_cells = self.all_cells[self._mask_local] 445 446 def _record(self, variable, record_from=None, rng=None, to_file=True): 447 """ 448 Private method called by record() and record_v(). 449 """ 450 pass 451 452 def meanSpikeCount(self): 453 return -1 454 455 def printSpikes(self, file, gather=True, compatible_output=True): 456 pass 457 458 def print_v(self, file, gather=True, compatible_output=True): 459 pass 390 460 391 461 class AlltoAllConnector(connectors.AllToAllConnector): … … 531 601 Projection.n += 1 532 602 533 534 # ============================================================================== 603 def saveConnections(self, filename, gather=True, compatible_output=True): 604 pass 605 606 def __len__(self): 607 return 0 # needs implementing properly 608 609 # ==============================================================================
