Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
spatial
/
__pycache__
/
File Content:
kdtree.cpython-35.opt-1.pyc
DB�Wg� � @ s� d d l m Z m Z m Z d d l Z d d l Z d d l m Z m Z d d l Z d d d d d g Z d d d � Z d d d � Z Gd d � d e � Z Gd d � d e � Z d d d d � Z d S)� )�division�print_function�absolute_importN)�heappush�heappop�minkowski_distance_p�minkowski_distance�distance_matrix� Rectangle�KDTree� c C s� t j | � } t j | � } | t j k rM t j t j | | � d d �S| d k ry t j t j | | � d d �St j t j | | � | d d �Sd S)a\ Compute the p-th power of the L**p distance between two arrays. For efficiency, this function computes the L**p distance but does not extract the pth root. If `p` is 1 or infinity, this is equal to the actual L**p distance. Parameters ---------- x : (M, K) array_like Input array. y : (N, K) array_like Input array. p : float, 1 <= p <= infinity Which Minkowski p-norm to use. Examples -------- >>> from scipy.spatial import minkowski_distance_p >>> minkowski_distance_p([[0,0],[0,0]], [[1,1],[0,1]]) array([2, 1]) �axis� N���r r )�np�asarray�inf�amax�abs�sum)�x�y�p� r � /kdtree.pyr s c C se t j | � } t j | � } | t j k s9 | d k rI t | | | � St | | | � d | Sd S)a� Compute the L**p distance between two arrays. Parameters ---------- x : (M, K) array_like Input array. y : (N, K) array_like Input array. p : float, 1 <= p <= infinity Which Minkowski p-norm to use. Examples -------- >>> from scipy.spatial import minkowski_distance >>> minkowski_distance([[0,0],[0,0]], [[1,1],[0,1]]) array([ 1.41421356, 1. ]) r g �?N)r r r r )r r r r r r r 1 s c @ s� e Z d Z d Z d d � Z d d � Z d d � Z d d � Z d d d � Z d d d � Z d d d � Z d d d � Z d S)r zLHyperrectangle class. Represents a Cartesian product of intervals. c C sR t j | | � j t � | _ t j | | � j t � | _ | j j \ | _ d S)zConstruct a hyperrectangle.N) r �maximumZastype�float�maxesZminimum�mins�shape�m)�selfr r r r r �__init__R s zRectangle.__init__c C s d t t | j | j � � S)Nz<Rectangle %s>)�list�zipr r )r! r r r �__repr__X s zRectangle.__repr__c C s t j | j | j � S)z Total volume.)r Zprodr r )r! r r r �volume[ s zRectangle.volumec C sf t j | j � } | | | <t | j | � } t j | j � } | | | <t | | j � } | | f S)a� Produce two hyperrectangles by splitting. In general, if you need to compute maximum and minimum distances to the children, it can be done more efficiently by updating the maximum and minimum distances to the parent. Parameters ---------- d : int Axis to split hyperrectangle along. split : float Position along axis `d` to split at. )r �copyr r r )r! �d�splitZmid�less�greaterr r r r) _ s zRectangle.splitg @c C s6 t d t j d t j | j | | | j � � | � S)z� Return the minimum distance between input and points in the hyperrectangle. Parameters ---------- x : array_like Input. p : float, optional Input. r )r r r r r )r! r r r r r �min_distance_pointw s zRectangle.min_distance_pointc C s* t d t j | j | | | j � | � S)z� Return the maximum distance between input and points in the hyperrectangle. Parameters ---------- x : array_like Input array. p : float, optional Input. r )r r r r r )r! r r r r r �max_distance_point� s zRectangle.max_distance_pointc C s<