Commit 56cd389f by Daniel Böckenhoff

### renaming

parent c1bba9b3
 ... ... @@ -846,21 +846,12 @@ class Tensors(AbstractNdarray): # in current implementation Points3D use always cut method, never MeshMap return self.cut(cutOrMeshMap, coordSys=coordSys), None def to3DArrays(self, arrayShape): def distances(self, other, **kwargs): """ Args: arrayShape (tuple of lenght 3): how coordinates will be devided. If you initialize Points3D with a grid of dimensions a,b,c and want to retrieve the grid-points use (a,b,c) """ if not isinstance(arrayShape, tuple): raise TypeError("ArrayShape is not of type tuple but %s" % type(arrayShape)) if not len(arrayShape) == 3: raise TypeError("ArrayShape is not of length 3 but %i" % len(arrayShape)) return self.T.reshape((3,) + arrayShape) def distances(self, other, metric='euclidean', **kwargs): """ other(array) **kwargs: ... is forwarded to sp.spatial.distance.cdist Examples: >>> p = tfields.Tensors.grid((0, 2, 3j), ... (0, 2, 3j), ... ... @@ -874,10 +865,21 @@ class Tensors(AbstractNdarray): array([ 3.]) """ return sp.spatial.distance.cdist(self, other, metric=metric, **kwargs) if issubclass(type(other), Tensors) and self.coordSys != other.coordSys: other = other.copy() other.transform(self.coordSys) return sp.spatial.distance.cdist(self, other, **kwargs) def minDistances(self, other=None, metric='euclidean', **kwargs): def minDistances(self, other=None, **kwargs): """ Args: other(array or None) **kwargs: memory_saving (bool): for very large array comparisons default False ... rest is forwarded to sp.spatial.distance.cdist Examples: >>> p = tfields.Tensors.grid((0, 2, 3), ... (0, 2, 3), ... ... @@ -888,31 +890,31 @@ class Tensors(AbstractNdarray): array([ 1. , 1. , 1. , 1. , 1.41421356, 1. , 1. , 1. , 1. ]) >>> dMin2 = p.minDistances(memorySaving=True) >>> dMin2 = p.minDistances(memory_saving=True) >>> bool((dMin2 == dMin).all()) True """ memorySaving = kwargs.pop('memorySaving', False) memory_saving = kwargs.pop('memory_saving', False) if other is not None: raise NotImplementedError("Should be easy but make shure not to remove 0s") else: if other is None: other = self else: raise NotImplementedError("Should be easy but make shure not to remove diagonal") try: if memorySaving: if memory_saving: raise MemoryError() d = self.distances(other, metric=metric, **kwargs) d = self.distances(other, **kwargs) return d[d > 0].reshape(d.shape[0], - 1).min(axis=1) except MemoryError: minDists = np.empty(self.shape[0]) min_dists = np.empty(self.shape[0]) for i, point in enumerate(other): d = self.distances([point], metric=metric, **kwargs) minDists[i] = d[d > 0].reshape(-1).min() return minDists d = self.distances([point], **kwargs) min_dists[i] = d[d > 0].reshape(-1).min() return min_dists def epsilonNeighbourhood(self, epsilon): def epsilon_neighbourhood(self, epsilon): """ Returns: indices for those sets of points that lie within epsilon around the other ... ... @@ -923,7 +925,7 @@ class Tensors(AbstractNdarray): ... (0, 1, 2j), ... (0, 1, 2j)) >>> p = tfields.Tensors.merged(p, [[0.5, 0.5, 0.5]]) >>> [len(en) for en in p.epsilonNeighbourhood(0.9)] >>> [len(en) for en in p.epsilon_neighbourhood(0.9)] [2, 2, 2, 2, 2, 2, 2, 2, 9] """ ... ... @@ -933,8 +935,6 @@ class Tensors(AbstractNdarray): return [indices[die] for die in distsInEpsilon] class TensorFields(Tensors): """ Discrete Tensor Field ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!