15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SciPy Reference Guide, Release 0.8.dev<br />

query(x, k=1, eps=0, p=2, distance_upper_bound=inf )<br />

query the kd-tree for nearest neighbors<br />

Parameters<br />

x : array-like, last dimension self.m<br />

An array of points to query.<br />

k : integer<br />

The number of nearest neighbors to return.<br />

eps : nonnegative float<br />

Return approximate nearest neighbors; the kth returned value is guaranteed to be<br />

no further than (1+eps) times the distance to the real kth nearest neighbor.<br />

p : float, 1> from <strong>scipy</strong>.spatial import KDTree<br />

>>> x, y = np.mgrid[0:5, 2:8]<br />

>>> tree = KDTree(zip(x.ravel(), y.ravel()))<br />

>>> tree.data<br />

array([[0, 2],<br />

[0, 3],<br />

[0, 4],<br />

[0, 5],<br />

[0, 6],<br />

[0, 7],<br />

[1, 2],<br />

[1, 3],<br />

[1, 4],<br />

[1, 5],<br />

[1, 6],<br />

[1, 7],<br />

[2, 2],<br />

[2, 3],<br />

418 Chapter 3. Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!