Changeset 725 for trunk/src/connectors.py
- Timestamp:
- 03/10/10 11:16:33 (2 years ago)
- Files:
-
- 1 modified
-
trunk/src/connectors.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/connectors.py
r722 r725 19 19 from numpy import arccos, arcsin, arctan, arctan2, ceil, cos, cosh, e, exp, \ 20 20 fabs, floor, fmod, hypot, ldexp, log, log10, modf, pi, power, \ 21 sin, sinh, sqrt, tan, tanh 21 sin, sinh, sqrt, tan, tanh, maximum, minimum 22 22 from pyNN import random, common, errors, core 23 23 from pyNN.space import Space … … 58 58 """Base class for Connector classes.""" 59 59 60 def __init__(self, weights=0.0, delays=None ):60 def __init__(self, weights=0.0, delays=None, space=None): 61 61 self.w_index = 0 # should probably use a generator 62 62 self.d_index = 0 # rather than storing these values … … 71 71 else: 72 72 self.delays = delays 73 74 73 if delays is None: 75 74 self.delays = common.get_min_delay() 75 if space is not None: 76 assert isinstance(space, Space) 77 self.space = space 76 78 77 79 def connect(self, projection): … … 95 97 return delays 96 98 99 def reset(self): 100 """ 101 After running connect(), this should be called to reset attributes that 102 have been modified to their initial values. 103 """ 104 if hasattr(self, "w_expr"): 105 self.weights = numpy.empty((1,0)) 106 if hasattr(self, "d_expr"): 107 self.delays = numpy.empty((1,0)) 108 self.w_index = 0 # should probably use a generator 109 self.d_index = 0 # rather than storing these values 110 97 111 98 112 class ProbabilisticConnector(Connector): … … 147 161 if len(targets) > 0: 148 162 projection.connection_manager.connect(src, targets, weights, delays) 149 163 self.reset() 150 164 151 165 class AllToAllConnector(ProbabilisticConnector): … … 169 183 to the global minimum delay. 170 184 """ 171 Connector.__init__(self, weights, delays )185 Connector.__init__(self, weights, delays, space) 172 186 assert isinstance(allow_self_connections, bool) 173 187 self.allow_self_connections = allow_self_connections … … 479 493 to the global minimum delay. 480 494 """ 481 Connector.__init__(self, weights, delays )495 Connector.__init__(self, weights, delays, space) 482 496 assert isinstance(allow_self_connections, bool) 483 497 self.allow_self_connections = allow_self_connections … … 521 535 to the global minimum delay. 522 536 """ 523 Connector.__init__(self, weights, delays )537 Connector.__init__(self, weights, delays, space) 524 538 assert isinstance(d_expression, str) 525 539 try: … … 529 543 raise ZeroDivisionError("Error in the distance expression %s. %s" % (d_expression, err)) 530 544 self.d_expression = d_expression 531 self.space = space532 545 assert isinstance(allow_self_connections, bool) 533 546 self.allow_self_connections = allow_self_connections 534 assert isinstance(space, Space)535 self.space = space536 547 537 548
