- Timestamp:
- 09/30/11 15:05:02 (8 months ago)
- Location:
- trunk/src
- Files:
-
- 5 modified
-
common.py (modified) (2 diffs)
-
nest/__init__.py (modified) (2 diffs)
-
nest/electrodes.py (modified) (4 diffs)
-
nest/recording.py (modified) (1 diff)
-
nest/simulator.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common.py
r979 r991 571 571 self.label, parametername, value_array.shape, 572 572 value_array.min(), value_array.max()) 573 except TypeError: # min() and max() won't work for non-numeric values573 except (TypeError,ValueError): # min() and max() won't work for non-numeric values 574 574 logger.debug("%s.tset('%s', non_numeric_array(shape=%s))", 575 575 self.label, parametername, value_array.shape) … … 885 885 else: 886 886 raise Exception("A maximum of 3 dimensions is allowed. What do you think this is, string theory?") 887 size = reduce(operator.mul, size)887 size = int(reduce(operator.mul, size)) # NEST doesn't like numpy.int, so to be safe we cast to Python int 888 888 self.size = size 889 889 self.label = label or 'population%d' % Population.nPop -
trunk/src/nest/__init__.py
r957 r991 193 193 # perhaps should check for that 194 194 assert n > 0, 'n must be a positive integer' 195 n = int(n) 196 195 197 celltype = cellclass(cellparams) 196 198 nest_model = celltype.nest_name[simulator.state.spike_precision] … … 325 327 self.synapse_model = synapse_dynamics._get_nest_synapse_model("projection_%d" % Projection.nProj) 326 328 Projection.nProj += 1 329 327 330 self.connection_manager = simulator.ConnectionManager(self.synapse_type, 328 331 self.synapse_model, -
trunk/src/nest/electrodes.py
r957 r991 100 100 """ 101 101 self._device = nest.Create('step_current_generator') 102 103 self._set(times,amplitudes) 104 105 106 def _set(self, times, amplitudes): 107 """Set currents in existing current source. 108 Arguments: 109 times -- list/array of times at which the injected current changes. 110 amplitudes -- list/array of current amplitudes to be injected at the 111 times specified in `times`. 112 113 The injected current will be zero up until the first time in `times`. The 114 current will continue at the final value in `amplitudes` until the end 115 of the simulation. 116 """ 102 117 assert len(times) == len(amplitudes), "times and amplitudes must be the same size (len(times)=%d, len(amplitudes)=%d" % (len(times), len(amplitudes)) 103 118 try: … … 109 124 except AttributeError: 110 125 numpy.append(amplitudes, amplitudes[-1]) 111 nest.SetStatus(self._device, {'amplitude_times': numpy.array(times, 'float'), 112 'amplitude_values': 1000.0*numpy.array(amplitudes, 'float')}) 113 114 126 nest.SetStatus(self._device, {'amplitude_times': list(numpy.array(times, 'float')), 127 'amplitude_values':list(1000.0*numpy.array(amplitudes, 'float'))}) 128 115 129 class NoisyCurrentSource(CurrentSource): 116 130 """A Gaussian "white" noise current source. The current amplitude changes at fixed … … 146 160 specified, a NumpyRNG is used. 147 161 """ 162 self._device = nest.Create('noise_generator') 163 self._set(mean, stdev, dt, start, stop, rng) 164 165 def _set(self, mean, stdev, dt=None, start=0.0, stop=None, rng=None): 148 166 self.rng = rng or NumpyRNG() 149 167 self.dt = dt or state.dt … … 155 173 self.stdev = stdev 156 174 if isinstance(rng, NativeRNG): 157 self._device = nest.Create('noise_generator')158 175 nest.SetStatus(self._device, {'mean': mean*1000.0, 159 176 'std': stdev*1000.0, -
trunk/src/nest/recording.py
r970 r991 271 271 except ValueError: 272 272 pass 273 274 if self._device != None: 275 recorders_to_reset=[] 276 for recorder in self.population.recorders.values(): 277 if hasattr(recorder, "_device") and recorder._device == self._device: 278 recorders_to_reset.append(recorder) 279 for recorder in recorders_to_reset: 280 recorder._device = None 273 281 self._create_device() 274 282 -
trunk/src/nest/simulator.py
r957 r991 128 128 gid = self 129 129 try: 130 #nest does not like numpy array and so we will convert them to lists whenever we encounter one 131 for key in parameters: 132 if type(parameters[key]) == numpy.ndarray: 133 parameters[key] = parameters[key].tolist() 130 134 nest.SetStatus([gid], [parameters]) 131 135 except: # I can't seem to catch the NESTError that is raised, hence this roundabout way of doing it.
