diff options
author | mdroe <mdroe@stsci.edu> | 2014-06-13 18:04:04 -0400 |
---|---|---|
committer | mdroe <mdroe@stsci.edu> | 2014-06-13 18:04:04 -0400 |
commit | e0211e21f3db0bb27a04490d712dabe04c0fed26 (patch) | |
tree | c48efb390b1baabb99ee349b2980d38b3e7f5bb6 /stsci/sphere/graph.py | |
parent | 99b3bdc918d81c78ed1583804bcfa0d42f123667 (diff) | |
download | stsci.sphere-e0211e21f3db0bb27a04490d712dabe04c0fed26.tar.gz |
More speedups.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@32541 fe389314-cf27-0410-b35b-8c050e845b92
Former-commit-id: 36e70c1cac043d59089f386a6b6d730c4887fa84
Diffstat (limited to 'stsci/sphere/graph.py')
-rw-r--r-- | stsci/sphere/graph.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/stsci/sphere/graph.py b/stsci/sphere/graph.py index 0fbc9a7..bae1c60 100644 --- a/stsci/sphere/graph.py +++ b/stsci/sphere/graph.py @@ -270,11 +270,17 @@ class Graph: # Don't add nodes that already exist. Update the existing # node's source_polygons list to include the new polygon. - point = vector.normalize_vector(*point) + point = vector.normalize_vector(point) - # TODO: Vectorize this - for node in self._nodes: - if np.all(np.abs(node._point - point) < 2 ** -32): + if len(self._nodes): + nodes = list(self._nodes) + node_array = np.array([node._point for node in nodes]) + + diff = np.all(np.abs(point - node_array) < 2 ** -32, axis=-1) + + indices = np.nonzero(diff)[0] + if len(indices): + node = nodes[indices[0]] node._source_polygons.update(source_polygons) return node |