Changeset 721
- Timestamp:
- 03/03/10 10:41:30 (2 years ago)
- Location:
- trunk/src
- Files:
-
- 2 modified
-
connectors.py (modified) (2 diffs)
-
space.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/connectors.py
r716 r721 134 134 create = create[:projection.post.local_cells.size] 135 135 targets = projection.post.local_cells[create].tolist() 136 137 136 weights = self.get_weights(N, local)[create] 138 137 weights = common.check_weight(weights, projection.synapse_type, is_conductance) … … 541 540 p = {} 542 541 for src in projection.pre.all(): 543 d = self.space.distances(src.position, projection.post.positions) 542 local = projection.post._mask_local.flatten() 543 d = self.space.distances(src.position, projection.post.positions, post_mask=local) 544 544 p[src] = eval(self.d_expression).flatten() 545 545 if p[src].dtype == 'bool': -
trunk/src/space.py
r712 r721 53 53 self.offset = offset 54 54 55 def distances(self, A, B ):55 def distances(self, A, B, post_mask=None): 56 56 """ 57 57 Calculate the distance matrix between two sets of coordinates, given … … 66 66 d = numpy.zeros((A.shape[1], B.shape[1]), dtype=A.dtype) 67 67 for axis in self.axes: 68 diff2 = A[axis,:,None] - B[axis, :]68 diff2 = A[axis,:,None] - B[axis, post_mask] 69 69 if self.periodic_boundaries is not None: 70 70 boundaries = self.periodic_boundaries[axis] 71 71 if boundaries is not None: 72 72 range = boundaries[1]-boundaries[0] 73 ad2 = abs(diff2)73 ad2 = abs(diff2) 74 74 diff2 = numpy.minimum(ad2, range-ad2) 75 75 diff2 **= 2 76 d += diff277 numpy.sqrt(d , d)76 d[:,post_mask] += diff2 77 numpy.sqrt(d[:,post_mask], d[:,post_mask]) 78 78 return d
