Changeset 322
- Timestamp:
- 06/04/08 16:38:40 (5 years ago)
- Location:
- trunk/src
- Files:
-
- 6 modified
-
common.py (modified) (6 diffs)
-
nest2/__init__.py (modified) (4 diffs)
-
nest2/connectors.py (modified) (2 diffs)
-
neuron/__init__.py (modified) (4 diffs)
-
neuron/connectors.py (modified) (1 diff)
-
random.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common.py
r310 r322 100 100 101 101 def __getattr__(self, name): 102 try: 103 val = self.get_parameters()[name] 104 except KeyError: 105 raise NonExistentParameterError(name, self.cellclass) 102 if name in IDMixin.non_parameter_attributes: 103 val = self.__getattribute__(name) 104 else: 105 try: 106 val = self.get_parameters()[name] 107 except KeyError: 108 raise NonExistentParameterError(name, self.cellclass) 106 109 return val 107 110 … … 368 371 'tau_m' : 20.0, # Membrane time constant in ms. 369 372 'tau_refrac' : 0.0, # Duration of refractory period in ms. 370 'tau_syn_E' : 0. 3, # Rise time of the excitatory synaptic alpha function in ms.373 'tau_syn_E' : 0.5, # Rise time of the excitatory synaptic alpha function in ms. 371 374 'tau_syn_I' : 0.5, # Rise time of the inhibitory synaptic alpha function in ms. 372 375 'i_offset' : 0.0, # Offset current in nA … … 624 627 625 628 def get_min_delay(): 626 pass 629 return 1e12 630 631 def get_max_delay(): 632 return -1e12 627 633 628 634 def num_processes(): … … 1164 1170 # --- Methods for writing/reading information to/from file. ---------------- 1165 1171 1172 def getWeights(self, format='list', gather=True): 1173 """ 1174 Possible formats are: a list of length equal to the number of connections 1175 in the projection, a 2D weight array (with zero or None for non-existent 1176 connections). 1177 """ 1178 return _abstract_method(self) 1179 1180 def getDelays(self, format='list', gather=True): 1181 """ 1182 Possible formats are: a list of length equal to the number of connections 1183 in the projection, a 2D delay array (with None or 1e12 for non-existent 1184 connections). 1185 """ 1186 return _abstract_method(self) 1187 1166 1188 def saveConnections(self, filename, gather=False): 1167 1189 """Save connections to file in a format suitable for reading in with the … … 1235 1257 else: 1236 1258 raise Exception("delays is of type %s" % type(self.delays)) 1237 assert numpy.all(delays >= get_min_delay()), "Delay values must be greater than the minimum delay %g" %get_min_delay() 1259 assert numpy.all(delays >= get_min_delay()), \ 1260 "Delay values must be greater than or equal to the minimum delay %g. The smallest delay is %g." % (get_min_delay(), delays.min()) 1261 assert numpy.all(delays <= get_max_delay()), \ 1262 "Delay values must be less than or equal to the maximum delay %s. The largest delay is %s" % (get_max_delay(), delays.max()) 1238 1263 self.d_index += N 1239 1264 return delays … … 1360 1385 'xy': [0,1], 'yz': [1,2], 'xz': [0,2], 'xyz': None, None: None} 1361 1386 1362 def __init__(self, d_expression, axes=None, scale_factor=1.0, offset=0. ,1387 def __init__(self, d_expression, axes=None, scale_factor=1.0, offset=0.0, 1363 1388 periodic_boundaries=False, allow_self_connections=True, 1364 1389 weights=0.0, delays=None): -
trunk/src/nest2/__init__.py
r318 r322 285 285 def get_max_delay(): 286 286 return nest.GetSynapseDefaults('static_synapse')['max_delay'] 287 common.get_max_delay = get_max_delay 287 288 288 289 def num_processes(): … … 479 480 480 481 if compatible_output: 481 if gather == False or nest.Rank() == 0: # if we gather, only do this on the master node 482 if gather == False: 483 user_filename += '.%d' % rank() 484 if gather == False or rank() == 0: # if we gather, only do this on the master node 482 485 recording.write_compatible_output(nest_filename, user_filename, 483 486 population, get_time_step()) … … 711 714 raise Exception('rset() not yet implemented for NativeRNG') 712 715 else: 713 rarr = rand_distr.next(n=len(self.cell_local)) 714 assert len(rarr) == len(self.cell_local) 716 #rarr = rand_distr.next(n=len(self.cell_local)) 717 rarr = rand_distr.next(n=self.size) 718 print rank(), self.cell_local[:5], self.cell_local[-5:], len(rarr), len(self.cell_local) 719 assert len(rarr) >= len(self.cell_local), "The length of rarr (%d) must be greater than that of cell_local (%d)" % (len(rarr), len(self.cell_local)) 720 rarr = rarr[:len(self.cell_local)] 715 721 for cell,val in zip(self.cell_local, rarr): 716 722 setattr(cell, parametername, val) … … 1269 1275 """Save connections to file in a format suitable for reading in with the 1270 1276 'fromFile' method.""" 1277 if gather == True: 1278 raise Exception("saveConnections(gather=True) not yet supported") 1279 else: 1280 filename += '.%d' % rank() 1271 1281 f = open(filename, 'w', DEFAULT_BUFFER_SIZE) 1272 1282 weights = []; delays = [] -
trunk/src/nest2/connectors.py
r304 r322 5 5 6 6 from pyNN import common 7 from pyNN.nest2.__init__ import nest, is_number 7 from pyNN.nest2.__init__ import nest, is_number, get_max_delay, get_min_delay 8 8 import numpy 9 9 # note that WDManager is defined in __init__.py imported here, then imported … … 79 79 return projection.pre.size 80 80 else: 81 raise Exception(" Connection method not yet implemented for the case where presynaptic and postsynaptic Populations havedifferent sizes.")81 raise Exception("OneToOneConnector does not support presynaptic and postsynaptic Populations of different sizes.") 82 82 83 83 class FixedProbabilityConnector(common.FixedProbabilityConnector): 84 84 85 85 def connect(self, projection): 86 postsynaptic_neurons = projection.post.cell.flatten()86 postsynaptic_neurons = projection.post.cell_local.flatten() 87 87 npost = projection.post.size 88 for pre in projection.pre.cell .flat:88 for pre in projection.pre.cell: 89 89 if projection.rng: 90 90 rarr = projection.rng.uniform(0, 1, (npost,)) # what about NativeRNG? 91 91 else: 92 92 rarr = numpy.random.uniform(0, 1, (npost,)) 93 if len(rarr) > len(postsynaptic_neurons): 94 rarr = rarr[:len(postsynaptic_neurons)] 93 95 target_list = numpy.compress(numpy.less(rarr, self.p_connect), postsynaptic_neurons).tolist() 94 96 # if self connections are not allowed, check whether pre and post are the same -
trunk/src/neuron/__init__.py
r310 r322 328 328 'pc = new ParallelContext()', 329 329 'dt = %f' % timestep, 330 'tstop = 0', 330 331 'min_delay = %g' % min_delay, 331 332 'create dummy_section', … … 407 408 if not running: 408 409 running = True 409 hoc_commands += ['tstop = 0', 410 'local_minimum_delay = pc.set_maxstep(10)', 410 hoc_commands += ['local_minimum_delay = pc.set_maxstep(10)', 411 411 'tmp = finitialize()',] 412 412 hoc_execute(hoc_commands,"--- run() ---") … … 752 752 raise common.InvalidDimensionsError 753 753 return coords 754 755 def index(self, n): 756 """Return the nth cell in the population (Indexing starts at 0).""" 757 if hasattr(n, '__len__'): 758 n = numpy.array(n) 759 return self.fullgidlist[n] 754 760 755 761 def get(self, parameter_name, as_array=False): … … 1166 1172 self.hoc_label = self.label.replace(" ","_") 1167 1173 if not rng: 1168 self.rng = numpy.random.RandomState()1174 self.rng = NumpyRNG() 1169 1175 hoc_commands = ['objref %s' % self.hoc_label, 1170 1176 '%s = new List()' % self.hoc_label] -
trunk/src/neuron/connectors.py
r310 r322 93 93 hoc_commands += self.singleConnect(projection, src, tgt, w, d) 94 94 else: 95 raise Exception(" Method '%s' not yet implemented for the case where presynaptic and postsynaptic Populations have different sizes." % sys._getframe().f_code.co_name)95 raise Exception("OneToOneConnector does not support presynaptic and postsynaptic Populations of different sizes.") 96 96 return hoc_commands 97 97 -
trunk/src/random.py
r308 r322 16 16 print "Warning: GSL random number generators not available" 17 17 import time 18 import logging 18 19 19 20 # The following two functions taken from … … 60 61 self.rng = numpy.random.RandomState() 61 62 if self.seed: 63 if not parallel_safe: 64 self.seed += rank # ensure different nodes get different sequences 65 if rank != 0: 66 logging.warning("Changing the seed to %s on node %d" % (self.seed, rank)) 62 67 self.rng.seed(self.seed) 63 68 else: … … 89 94 raise ValueError, "The sample number must be positive" 90 95 if self.parallel_safe and self.num_processes > 1: 91 # strip out the random numbers that should be used on other processors 96 # strip out the random numbers that should be used on other processors. 97 # This assumes that the first neuron in a population is always created on 98 # the node with rank 0, and that neurons are distributed in a round-robin 99 # This assumption is not true for NEST 92 100 rarr = rarr[numpy.arange(self.rank, len(rarr), self.num_processes)] 93 101 return rarr
