o
    ?HhTW                    @   s  d dl Z d dlZd dlmZmZ d dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZmZmZmZmZmZ d dlZd dlZd dlmZmZmZmZmZmZmZmZm Z  d dlm!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 d dl6m7Z7m8Z8 ej9e dd	d
d Z:g dZ;ej<g dg dg dg dg dg dgddZ=ee=Z>i Z?dd Z@e@  dd ZAd~ddZB					dddZCdd  ZDd!d" ZEd~d#d$ZFeed%d&ZGeGd'd( dfd)d*ZHd+dd,d( d-ddddddddddd.d eGfd/d0ZIG d1d2 d2ZJdeKfd3d4ZLeIed5dd6ZMeIed5ddd7ZNeIed5dd5d8ZOeIed5ddd5d9ZPeIe/ZQeIe)dd: ZRZSeIe5ZTeIe'ZUeIe$ZVeIe#ZWeIe&ZXeIe%ZYeIe,ZZeIe*Z[eIe(dd;Z\eIe4dd;Z]eIe!Z^eIe"dd;Z_eIe3Z`eIe2ZaeIe0ZbG d<d= d=ZcG d>d? d?ZdG d@dA dAZeG dBdC dCZfG dDdE dEZgG dFdG dGZhdHdI ZiG dJdK dKZjdLdM ZkG dNdO dOZlejmndPg dQdRdS ZodTdU ZpdVdW ZqdXdY ZrdZd[ Zsd\d] Ztd^d_ Zud`da Zvdbdc Zwddde Zxejmjydfdg Zzejmjydhdi Z{ejmjydjdk Z|ejmjydldm Z}ejmjydndo Z~dpdq Zdrds Zdtdu Zdvdw Zejmjydxdy ZG dzd{ d{ZG d|d} d}ZdS )    N)wrapspartial)norm)verboseassert_assert_array_equalassert_equalassert_almost_equalassert_allclosebreak_cyclesIS_PYPY)	
squareformpdistcdist	num_obs_y
num_obs_dmis_valid_dm
is_valid_y_validate_vector_METRICS_NAMES)
braycurtiscanberra	chebyshev	cityblockcorrelationcosinedice	euclideanhammingjaccardjensenshannonkulczynski1mahalanobis	minkowskirogerstanimoto
russellrao
seuclideansokalmichenersokalsneathsqeuclideanyule)np_longnp_ulongsession)paramsscopec                 C   s   | j S )z;
    Fixture for all metrics in scipy.spatial.distance
    )param)request r2   a/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/scipy/spatial/tests/test_distance.pymetricD   s   r4   )zcdist-X1.txtzcdist-X2.txtziris.txtzpdist-boolean-inp.txtzpdist-chebyshev-ml-iris.txtzpdist-chebyshev-ml.txtzpdist-cityblock-ml-iris.txtzpdist-cityblock-ml.txtzpdist-correlation-ml-iris.txtzpdist-correlation-ml.txtzpdist-cosine-ml-iris.txtzpdist-cosine-ml.txtzpdist-double-inp.txtzpdist-euclidean-ml-iris.txtzpdist-euclidean-ml.txtzpdist-hamming-ml.txtzpdist-jaccard-ml.txtzpdist-jensenshannon-ml-iris.txtzpdist-jensenshannon-ml.txtzpdist-minkowski-3.2-ml-iris.txtzpdist-minkowski-3.2-ml.txtzpdist-minkowski-5.8-ml-iris.txtzpdist-seuclidean-ml-iris.txtzpdist-seuclidean-ml.txtzpdist-spearman-ml.txtzrandom-bool-data.txtzrandom-double-data.txtzrandom-int-data.txtzrandom-uint-data.txt)r     m         )r5   r   '        )r6   r:   r     4     )r7   r;   r>   r      e  )r8   r<   r?   rA   r     )r9   r=   r@   rB   rC   r   doubledtypec                  C   s   t D ]'} | dddd}tjtjtd| }t|}t	|t
|< |  qtt
d t
d< tt
d t
d< tt
d t
d< tt
d	 t
d	< tt
d
 t
d
< d S )Nz.txt z-mldatapdist-boolean-inprandom-bool-datarandom-double-datarandom-float32-datarandom-int-datarandom-uint-data)
_filenamesreplaceospathjoindirname__file__opennploadtxteoclosebool_float32r+   r,   )fnnamefqfnfpr2   r2   r3   load_testing_files{   s   
ra   c                   C   s   t djdk S )Nr      )rW   intpitemsizer2   r2   r2   r3   	_is_32bit   s   re   c                    s|   dd  D  |d u rdd  D  d}t dd  D  |dk r9t fdd D s0tdt d j| } |f S )	Nc                 S      g | ]}t |qS r2   )rW   
asanyarray.0ar2   r2   r3   
<listcomp>       z!_chk_asarrays.<locals>.<listcomp>c                 S   s$   g | ]}|j d krt|n|qS    )ndimrW   ravelrh   r2   r2   r3   rk      s    r   c                 s   s    | ]}t |V  qd S N)rW   
atleast_1drh   r2   r2   r3   	<genexpr>       z _chk_asarrays.<locals>.<genexpr>c                 3   s     | ]}|j  d  j kV  qdS )r   N)ro   rh   arraysr2   r3   rs          z(array ndim must be the same for neg axis)tupleall
ValueErrorrangero   )rv   axisr2   ru   r3   _chk_asarrays   s   
r}   FTc
                    sp  t |  d}
|
d d |
d }  |o| }|s#|r#tdd | D }|r@dd | D }t|r@d}d}tdd t| |D } d urJtn|rWt| d	 j  n|  f S |	rct|rkt	|  t
 fd
d| D s{td|rd	k  rtd|rtd	kd	 jjk rt fdd| D }  |rdk
 rd |  f S )Nr|   c                 s   s$    | ]}t j|t jjuV  qd S rq   )rW   magetmasknomaskrh   r2   r2   r3   rs      s   " z_chk_weights.<locals>.<genexpr>c                 S   s   g | ]
}t t |qS r2   )rW   isnansumrh   r2   r2   r3   rk          z _chk_weights.<locals>.<listcomp>Tc                 s   s(    | ]\}}|rt j|n|V  qd S rq   rW   r   masked_invalid)ri   rj   has_nanr2   r2   r3   rs      s    r   c                 3   s"    | ]}j |j   fkV  qd S rq   shaperh   )r|   weightsr2   r3   rs      s     z*weights shape must match arrays along axiszweights cannot be negativec                 3   s     | ]}t j| d V  qdS )r~   N)rW   takerh   )r|   pos_weightsr2   r3   rs      rw   rn   )r}   anyrx   ziprW   rg   onesr   _freq_weights_weight_maskedry   rz   nonzerosize)rv   r   r|   force_weightssimplify_weightspos_only	neg_check
nan_screenmask_screenddofchkedhas_nansr2   )r|   r   r   r3   _chk_weights   sD   
r   c                 C   s4   | d u r| S |  t}| |k rtd|  |S )Nz0frequency (integer count-type) weights required )astypeintr   rz   )r   int_weightsr2   r2   r3   r      s   
r   c                    s    d u rd t |}| D ]1}t j|}|t jju rq|jdkr5t fddt|jD }|j|d}|d|	t
 9 }q|S )Nr   rn   c                 3   s    | ]	}| kr|V  qd S rq   r2   ri   ir~   r2   r3   rs      s    z!_weight_masked.<locals>.<genexpr>r~   )rW   rg   r   r   r   ro   rx   r{   r   r   r   )rv   r   r|   rj   	axis_masknot_axesr2   r~   r3   r      s   

r   c           	         s   dd | D } t j|t jd}t j|}dd | d j  t fdd| D s0J d	tt| D ],}|	| | }|
 }|| |< t |d
| | } fdd| D } q8| |fS )Nc                 S   s,   g | ]}t |jt jr|t jn|qS r2   )rW   
issubdtyperF   integerr   float64)ri   arrr2   r2   r3   rk      s
    z_rand_split.<locals>.<listcomp>rE   c                    s6   t t j |d}| fddt jD S )Nr~   c                    s"   g | ]}|kr j | nd qS rm   r   r   rj   r|   r2   r3   rk      s    z/_rand_split.<locals>.mytake.<locals>.<listcomp>)rW   rg   r   reshaper{   ro   )rj   ixr|   recordr2   r   r3   mytake   s   z_rand_split.<locals>.mytaker   c                 3   s    | ]
}|j   kV  qd S rq   r   rh   )r|   n_obsr2   r3   rs      s    z_rand_split.<locals>.<genexpr>z#data must be aligned on sample axis      ?c              	      s&   g | ]}t j|| d  d qS r~   rW   appendrh   )r|   r   split_ixr2   r3   rk      s
    
)rW   arrayr   randomRandomStater   ry   r{   r   randintrandr   )	rv   r   r|   	split_perseedseeded_randr   prev_wqr2   )r|   r   r   r   r3   _rand_split   s(   r   h㈵>atolc                 C      | S rq   r2   xr2   r2   r3   <lambda>      r   c           	   	   C   s   || }||}zt ||k r||| W d S W d S  ty+   ||| Y d S  ttfyG   t||D ]\}}t|||d q8Y d S w )N)compare_assert)rW   r   r   AttributeError	TypeErrorrz   r   _rough_check)	rj   br   keywcheck_acheck_ba_ib_ir2   r2   r3   r     s   r      c                 C   r   rq   r2   r   r2   r2   r3   r     r   r   r   c                    s8   t  	
fdd}|S )zruns fn on its arguments 2 or 3 ways, checks that the results are the same,
       then returns the same thing it would have returned beforec               
      s  | i |}| d 	 }| 	d  }| d }| d t|| ddd}|d d |d |d }} rAdd |D }zt|| } r[||< t|| i |d r|d	 |< t|| i |d |d
 |< zt|| i |d W n ty } z
t||||f|d }~ww rrt|| d\}}	||	d |j< d|	|jd < t|| }
|	|< t||
i |d |D ]}td g|j	 }t|jd | < t|}|| d ||< qt|| }
t||
i |d |D ] }td g|j	 }t|jd | < t|}|| t
j ||< q| dd dkr@
r@t|| }
t||
i |d rodd |D }t|| }
t||
i |d rod |< t||
i |d ~~
~	r fdd|D }t
||d }t|| }||< t||i |d ~~~r͈dkrt|| d}|\}}t|| }||< t||i |d W |S W |S W |S  ty } zstjj d| dd W Y d }~|S W Y d }~|S d }~ww )Nr|   T)r   r|   r   r   r   c                 S   s   g | ]	}t | qS r2   )rW   rr   squeezerh   r2   r2   r3   rk   +  s    z4_weight_checked.<locals>.wrapped.<locals>.<listcomp>)r   g     @Y@gB`"۹?)r   r   r   e   
nan_policyomitc                 S   s   g | ]}t j|qS r2   r   rh   r2   r2   r3   rk   Y  s    c                    s   g | ]
}t j|| d qS r   r   rh   r~   r2   r3   rk   c  r          @z NotImplemented weights:    )
stacklevel)getr   rx   r   	Exceptiontyper   r   slicero   rW   nanr   NotImplementedErrorwarningswarn__name__)argskwargsresultrv   restr   r   e
dud_arraysdud_weightsdud_argsrj   indexer
dup_arraysdup_weightsdup_argssplitsplit_arrayssplit_weights
split_args
const_testdefault_axisdud_testdup_testr]   r   ma_safema_very_safen_argsnan_safe	ones_testr   silentr   
split_testr   
weight_argr~   r3   wrapped  s    

z _weight_checked.<locals>.wrapped)r   )r]   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r   r   r  r2   r   r3   _weight_checked  s   .Zr  c                   @   s   e Zd Zdd Zdd ZdS )DummyContextManagerc                 C      d S rq   r2   selfr2   r2   r3   	__enter__}     zDummyContextManager.__enter__c                 G   r  rq   r2   )r  r   r2   r2   r3   __exit__  r	  zDummyContextManager.__exit__N)r   
__module____qualname__r  r
  r2   r2   r2   r3   r  |  s    r  c                 C   s   | dv rt  S t S )N)r!   r'   )pytestdeprecated_callr  r4   r2   r2   r3   maybe_deprecated  s   r  rn   )r   r   )r   r   r   )r   r   r   )r   r   r   r   )r   )r   c                   @   s   e Zd Zdd Zejjdd Zdd Zdd Z	ej
d	d
ddddddejgdd Zdd Zdd Zdd Zd'ddZdd Zdd Zejjd d! Zejjd"d# Zejjd$d% Zd&S )(	TestCdistc                 C   @   g d| _ tttjtjgttjtjgtjtjgtjgd| _d S N)rL   rM   rN   rK   rJ   )booluintr   r\   rnd_eo_namesr,   r+   rW   r\   r   valid_upcastsr  r2   r2   r3   setup_method     

zTestCdist.setup_methodc              	   C   s^  g dg dg dg}g dg dg dg}dt dd	}dgd
 }tt' t| t||fd|i| W d    n1 sCw   Y  W d    n1 sRw   Y  tt) t| t||fdt|i| W d    n1 syw   Y  W d    n1 sw   Y  tt) t| t||fdd| i| W d    n1 sw   Y  W d    n1 sw   Y  tt t||g|R d|i W d    n1 sw   Y  tt t||g|R dt|i W d    n	1 sw   Y  tt t||g|R dd| i W d    d S 1 s(w   Y  d S )Nr   r         @333333?ffffff@333333@皙@r  皙@g      @      @g       @g      @333333@g @g      @r'  r#  Q	@r   N0tV4l1D_p4raMr      r4   test_)rW   aranger  raisesr   r  r   eval)r  r4   X1X2r   r   r2   r2   r3   test_cdist_extra_args  s>   



$zTestCdist.test_cdist_extra_argsc              	   C   s  ddd}g dg dg dg}g dg d	g d
g}dt dd}dgd }tt t||| W d    n1 s>w   Y  tt t|||g|R   W d    n1 s]w   Y  tt t|||fi | W d    n1 s|w   Y  tt t|||ddd W d    n1 sw   Y  tt t|||dddd W d    n1 sw   Y  tt t|||dddd W d    n1 sw   Y  tt t|||ddd W d    n1 sw   Y  tt t|||dd W d    n	1 sw   Y  tt t|||d W d    n	1 s1w   Y  tt t|||dddd W d    n	1 sQw   Y  tt|||dddd d S )Nrn   r   c                 S      || | S rq   r2   r   yargkwargkwarg2r2   r2   r3   
_my_metric     z:TestCdist.test_cdist_extra_args_custom.<locals>._my_metricr  r  r!  r$  r&  r(  r)  r   r*  r,  r"  ffffff
@r8  r9  r8  皙?r4   r7  r9  皙@rn   r   )rW   r.  r  r/  r   r   r
   )r  r:  r1  r2  r   r   r2   r2   r3   test_cdist_extra_args_custom  sP   


z&TestCdist.test_cdist_extra_args_customc                 C   sD   d}t d }t d }t||d}t||d}t|||tdkd d S )NV瞯<cdist-X1cdist-X2r   test_euclideanr   rtolr   rY   wcdist_no_constr
   r   )r  epsr1  r2  Y1Y2r2   r2   r3   #test_cdist_euclidean_random_unicode  s   z-TestCdist.test_cdist_euclidean_random_unicodep皙?      ?r   Gz?r   gffffff@gffffff@c                 C   sN   d}t d }t d }t||d|d}t||d|d}t||d|tdkd	 d S )
NvIh%<=rE  rF  r#   rP  test_minkowskir   r   )r   rI  r   rJ  )r  rP  rL  r1  r2  rM  rN  r2   r2   r3   test_cdist_minkowski_random  s   z%TestCdist.test_cdist_minkowski_randomc                 C   sb   d}t d }t d }t||d}dd }dt||| ||| j }t|||tdkd	 d S )
N+=rE  rF  r   c                 S   s   t jj| ddddS )Nrn   r~   r   )rW   linalgr   r   )Xr2   r2   r3   norms     z1TestCdist.test_cdist_cosine_random.<locals>.normsrn   r   rH  )rY   wcdistrW   dotTr
   r   )r  rL  r1  r2  rM  r[  rN  r2   r2   r3   test_cdist_cosine_random  s   "z"TestCdist.test_cdist_cosine_randomc                 C   s  t dgdgg}t dgdgg}t||dd}t|dt dgt dt dgg t d	d	gd
d	gg}t d	dgdd	gd	dgg}t||dd}t d}t||||gdd| dgg tt td	dggddggdd W d    d S 1 sw   Y  d S )Nr   r      r"   r                @      ?r   r   rn   r   )rW   r   r   r
   sqrtr  r/  rz   )r  x1x2distrt2r2   r2   r3   test_cdist_mahalanobis  s   (
"z TestCdist.test_cdist_mahalanobisc                    sV   G dd d  fdd}t j  ggtd}t|||d}d}t||tdkd	 d S )
Nc                   @      e Zd ZdS )z6TestCdist.test_cdist_custom_notdouble.<locals>.myclassNr   r  r  r2   r2   r2   r3   myclass      rm  c                    (   t | d  rt |d  stddS Nr   zType has been changed+?
isinstancerz   r   r6  rm  r2   r3   r:  !     z9TestCdist.test_cdist_custom_notdouble.<locals>._my_metricrE   r  rq  r   r   )rW   r   objectr   r   r   )r  r:  rH   cdist_yright_yr2   ru  r3   test_cdist_custom_notdouble  s   z%TestCdist.test_cdist_custom_notdoubleHz>c                 K   s  z't ||fd|i|}t ||fdt|i|}t ||fdd| i|}W n ty }	 z|	j}
tdkr?t|
j t|	 t|
 t ||fd|i| W d    n1 sZw   Y  t|
 t ||fdt|i| W d    n1 s|w   Y  t|
 t ||fdd| i| W d    n1 sw   Y  W Y d }	~	d S W Y d }	~	d S d }	~	ww t	|||tdkd t	|||tdkd d S Nr4   r-  r   rH  )
r   r0  r   	__class__r   printr   r  r/  r
   )r  r1  r2  r4   rL  r   y1y2y3r   e_clsr2   r2   r3   _check_calling_conventions*  s,   
8z$TestCdist._check_calling_conventionsc                 C   s  | j D ]}t| d d dd d df }t| dd dd d df }tdkr,td|d| |dv r5d|vr5q| ||| |d	kr]t||gtj}tj	|d
dd}| j||||d q|dkrt||gtj}t
t|j}ttj|j}| j||||d qd S )Nra  r   rn   r   	testing:  with: >   r   r*   r%   r!   r(   r'   r$   r  r&   r   r|   r   Vr"   VI)r  rY   r   r  r  rW   vstackr   r   var
atleast_2dcovr_  r   rY  inv)r  r4   eo_namer1  r2  X12r  r  r2   r2   r3   test_cdist_calling_conventions?  s(   
z(TestCdist.test_cdist_calling_conventionsc                 C   st  d}t d | jd ft d | jd ft d | jd ft d | jd	 fg}|D ]}|d
 d d dd d df }|d
 dd dd d df }z	t|||d}W nM ty } zA|j}	tdkret|	j t| |d D ]&}
|
|}|
|}t	|	 t|||d W d    n1 sw   Y  qiW Y d }~q&d }~ww |d D ]}
t|
||
||d}t
|||tdkd qq&d S )Nr|  rJ   r  rN   r  rM   r   rL   r\   r   ra  r   rn   r   r  rH  )rY   r  r   r   r~  r   r  r   r  r/  r
   )r  r4   rL  teststestr1  r2  r  r   r  new_typeX1newX2newr  r2   r2   r3   test_cdist_dtype_equivalence^  s>   
z&TestCdist.test_cdist_dtype_equivalencec              	   C   s.  d}t d }t d }|jd |jd }}t }|dkr d|d< tj||ftjd}t| t|||fi |}	W d    n1 sCw   Y  t| t|||fd	|i|}
W d    n1 scw   Y  t|	|
|t	d
kd t
|
|u  tj|d |d ftjd}tt( t| t|||fd	|i| W d    n1 sw   Y  W d    n1 sw   Y  tjd
| d
| ftjdd d d
d d d
f }tj||ftjdd}tt( t| t|||fd	|i| W d    n1 sw   Y  W d    n	1 sw   Y  tt) t| t|||fd	|i| W d    n	1 s6w   Y  W d    n	1 sFw   Y  tj||ftjd}tt2 t| t|||fd	|i| W d    n1 sww   Y  W d    d S W d    d S 1 sw   Y  d S )NrD  rE  rF  r   r#   rS  rP  rE   outr   rH  rn   F)rF   order)rY   r   dictrW   emptyr   r  r   r
   r   r   r  r/  rz   int64)r  r4   rL  r1  r2  out_rout_cr   out1rM  rN  out2out3out4out5r2   r2   r3   test_cdist_outy  sb   





 $zTestCdist.test_cdist_outc           
      C   s:  d}t d d d dd d df }t d d d dd d df }| }| }t|| t|| t|jj  t|jj  t|jj t|jj t }|dkrUd|d< t| t|||fi |}W d    n1 snw   Y  t| t|||fi |}	W d    n1 sw   Y  t	||	|t
dkd d S )	NrD  rE  r   rF  r#   rS  rP  rH  )rY   copyr   r   flagsc_contiguousr  r  r   r
   r   )
r  r4   rL  r1  r2  X1_copyX2_copyr   rM  rN  r2   r2   r3   test_striding  s*   



zTestCdist.test_stridingc                 C   s   t jdd}t jdd}t }|dkrd|d< t| t||fd|i|}W d    n1 s3w   Y  dd |||fD }~~~trJt  tdd	 |D sUJ d S )
N
   r#   rS  rP  r4   c                 S   rf   r2   )weakrefref)ri   vr2   r2   r3   rk     rl   z1TestCdist.test_cdist_refcount.<locals>.<listcomp>c                 s   s    | ]}| d u V  qd S rq   r2   )ri   weak_refr2   r2   r3   rs     rt   z0TestCdist.test_cdist_refcount.<locals>.<genexpr>)	rW   r   r   r  r  r   r   r   ry   )r  r4   rf  rg  r   r  	weak_refsr2   r2   r3   test_cdist_refcount  s   
zTestCdist.test_cdist_refcountNr|  )r   r  r  r  r  markthread_unsafer3  rC  rO  parametrizerW   infrW  r`  rj  r{  r  r  r  r  r  r  r2   r2   r2   r3   r    s,    	
$



-
r  c                	   @   sJ  e Zd Zdd Zejjdd Zdd Zdd Z	d	d
 Z
dd Zdd Zejjdd Zejjdd Zejjdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zejjd'd( Zejjd)d* Zejjd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Z ejjd5d6 Z!ejjd7d8 Z"ejjd9d: Z#d;d< Z$d=d> Z%d?d@ Z&ejjdAdB Z'ejjdCdD Z(ejjdEdF Z)ej*dGdHdIdJdKdLe+j,gdMdN Z-dOdP Z.dQdR Z/dSdT Z0ejjdUdV Z1ejjdWdX Z2ejjdYdZ Z3ejjd[d\ Z4ejjd]d^ Z5ejjd_d` Z6dadb Z7dcdd Z8dedf Z9dgdh Z:didj Z;dkdl Z<dmdn Z=dodp Z>dqdr Z?dsdt Z@dudv ZAdwdx ZBdydz ZCd{d| ZDd}d~ ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOejjdd ZPdd ZQdd ZRdddZSdd ZTdd ZUejjdd ZVejjdd ZWdS )	TestPdistc                 C   r  r  r  r  r2   r2   r3   r    r  zTestPdist.setup_methodc              	   C   s:  ddgddgddgg}dt dd}dgd	 }tt& t| t|fd
|i| W d    n1 s7w   Y  W d    n1 sFw   Y  tt( t| t|fd
t|i| W d    n1 slw   Y  W d    n1 s{w   Y  tt( t| t|fd
d| i| W d    n1 sw   Y  W d    n1 sw   Y  tt t|g|R d
|i W d    n1 sw   Y  tt t|g|R d
t|i W d    n1 sw   Y  tt t|g|R d
d| i W d    d S 1 sw   Y  d S )Nr   r   r  r  r"  r)  r   r*  r,  r4   r-  )rW   r.  r  r/  r   r  r   r0  )r  r4   r1  r   r   r2   r2   r3   test_pdist_extra_args  s<   



$zTestPdist.test_pdist_extra_argsc                 C   s  ddd}ddgddgd	dgg}d
t dd}d
gd }tt t|| W d    n1 s2w   Y  tt t||g|R   W d    n1 sPw   Y  tt t||fi | W d    n1 snw   Y  tt t||d	dd W d    n1 sw   Y  tt t||ddd	d W d    n1 sw   Y  tt t||ddd	d W d    n1 sw   Y  tt t||dd	d W d    n1 sw   Y  tt t||dd	 W d    n	1 sw   Y  tt t||d W d    n	1 sw   Y  tt t||dd	dd W d    n	1 s<w   Y  tt||dddd d S )Nrn   r   c                 S   r4  rq   r2   r5  r2   r2   r3   r:    r;  z:TestPdist.test_pdist_extra_args_custom.<locals>._my_metricr   r   r  r  r"  r)  r*  r,  r<  r=  r>  r?  r@  rA  rB  )rW   r.  r  r/  r   r   r
   )r  r:  r1  r   r   r2   r2   r3   test_pdist_extra_args_custom  sN   

z&TestPdist.test_pdist_extra_args_customc                 C   0   d}t d }t d }t|d}t|||d d S Nr|  pdist-double-inppdist-euclideanr   rI  rY   wpdist_no_constr
   r  rL  rZ  Y_rightY_test1r2   r2   r3   test_pdist_euclidean_random  
   
z%TestPdist.test_pdist_euclidean_randomc                 C   r  r  r  r  r2   r2   r3   test_pdist_euclidean_random_u&  r  z'TestPdist.test_pdist_euclidean_random_uc                 C   6   d}t td }td }t|d}t|||d d S r  rW   r\   rY   r  r
   r  r2   r2   r3   #test_pdist_euclidean_random_float32-  
   
z-TestPdist.test_pdist_euclidean_random_float32c                 C   r  )Nr|  r  r  rG  r  r  r  rL  rZ  r  Y_test2r2   r2   r3    test_pdist_euclidean_random_nonC4  r  z*TestPdist.test_pdist_euclidean_random_nonCc                 C   r  )Nr|  irispdist-euclidean-irisr   r  r  r  r2   r2   r3    test_pdist_euclidean_iris_double;  
   
z*TestPdist.test_pdist_euclidean_iris_doublec                 C   <   d}t td }td }t|d}t|||tdkd d S )Nr   r  r  r   r   rH  rW   r\   rY   r  r
   r   r  r2   r2   r3   !test_pdist_euclidean_iris_float32C  
   
z+TestPdist.test_pdist_euclidean_iris_float32c                 C   r  )Nr|  r  r  rG  r  r  r  r2   r2   r3   test_pdist_euclidean_iris_nonCK  
   
z(TestPdist.test_pdist_euclidean_iris_nonCc                 C   r  )Nr|  r  pdist-seuclideanr&   r  rY   r   r
   r  r2   r2   r3   test_pdist_seuclidean_randomU  r  z&TestPdist.test_pdist_seuclidean_randomc                 C   sb   d}t td }td }t|d}t|||d t j|ddd}t|d|d	}t|||d d S )
Nr|  r  r  r&   r  r   rn   r  r  )rW   r\   rY   r   r
   r  )r  rL  rZ  r  r  r  r  r2   r2   r3   $test_pdist_seuclidean_random_float32\  s   
z.TestPdist.test_pdist_seuclidean_random_float32c                 C   r  )Nr|  r  r  test_seuclideanr  r  r  r2   r2   r3   !test_pdist_seuclidean_random_nonCh  r  z+TestPdist.test_pdist_seuclidean_random_nonCc                 C   r  )Nr|  r  pdist-seuclidean-irisr&   r  r  r  r2   r2   r3   test_pdist_seuclidean_irisp  r  z$TestPdist.test_pdist_seuclidean_irisc                 C   r  )Nr   r  r  r&   r  )rW   r\   rY   r   r
   r  r2   r2   r3   "test_pdist_seuclidean_iris_float32w  s
   
z,TestPdist.test_pdist_seuclidean_iris_float32c                 C   r  )Nr|  r  r  r  r  r  r  r2   r2   r3   test_pdist_seuclidean_iris_nonC  s
   
z)TestPdist.test_pdist_seuclidean_iris_nonCc                 C   r  Nr|  r  pdist-cosiner   r  rY   wpdistr
   r  r2   r2   r3   test_pdist_cosine_random  r  z"TestPdist.test_pdist_cosine_randomc                 C   r  r  rW   r\   rY   r  r
   r  r2   r2   r3    test_pdist_cosine_random_float32  r  z*TestPdist.test_pdist_cosine_random_float32c                 C   r  )Nr|  r  r  test_cosiner  r  r  r2   r2   r3   test_pdist_cosine_random_nonC  r  z'TestPdist.test_pdist_cosine_random_nonCc                 C   r  )Nr   r  pdist-cosine-irisr   r   r  r  r2   r2   r3   test_pdist_cosine_iris  r  z TestPdist.test_pdist_cosine_irisc                 C   r  )Nr   r  r  r   r   r   r   )rW   r\   rY   r  r
   r   r  r2   r2   r3   test_pdist_cosine_iris_float32  r  z(TestPdist.test_pdist_cosine_iris_float32c                 C   r  )Nr   r  r  r  r   r  r  r2   r2   r3   test_pdist_cosine_iris_nonC  r  z%TestPdist.test_pdist_cosine_iris_nonCc                 C   sD   t t jdd}t ||g}tt|dd dkdd d S )Ni9  [   r   r   z&cosine distance should be non-negative)msg)rW   absr   r   r   r  r   r  )r  r   rZ  r2   r2   r3   test_pdist_cosine_bounds  s
   
z"TestPdist.test_pdist_cosine_boundsc                 C   r  Nr|  r  pdist-cityblockr   r  r  r  r2   r2   r3   test_pdist_cityblock_random  r  z%TestPdist.test_pdist_cityblock_randomc                 C   r  r  r  r  r2   r2   r3   #test_pdist_cityblock_random_float32  r  z-TestPdist.test_pdist_cityblock_random_float32c                 C   r  )Nr|  r  r  test_cityblockr  r  r  r2   r2   r3    test_pdist_cityblock_random_nonC  r  z*TestPdist.test_pdist_cityblock_random_nonCc                 C   r  )NrX  r  pdist-cityblock-irisr   r  r  r  r2   r2   r3   test_pdist_cityblock_iris  r  z#TestPdist.test_pdist_cityblock_irisc                 C   r  )Nr   r  r  r   r   rH  r  r  r2   r2   r3   !test_pdist_cityblock_iris_float32  r  z+TestPdist.test_pdist_cityblock_iris_float32c                 C   r  )NrX  r  r  r  r  r  r  r2   r2   r3   test_pdist_cityblock_iris_nonC  r  z(TestPdist.test_pdist_cityblock_iris_nonCc                 C   r  Nr|  r  pdist-correlationr   r  r  r  r2   r2   r3   test_pdist_correlation_random  r  z'TestPdist.test_pdist_correlation_randomc                 C   r  r  r  r  r2   r2   r3   %test_pdist_correlation_random_float32  r  z/TestPdist.test_pdist_correlation_random_float32c                 C   r  )Nr|  r  r  test_correlationr  r  r  r2   r2   r3   "test_pdist_correlation_random_nonC  r  z,TestPdist.test_pdist_correlation_random_nonCc                 C   r  )Nr|  r  pdist-correlation-irisr   r  r  r  r2   r2   r3   test_pdist_correlation_iris  r  z%TestPdist.test_pdist_correlation_irisc                 C   s<   d}t d }tt d }t|d}t|||tdkd d S )Nr|  r  r  r   r   rH  )rY   rW   r\   r  r
   r   r  r2   r2   r3   #test_pdist_correlation_iris_float32  s
   
z-TestPdist.test_pdist_correlation_iris_float32c                 C   sF   t jdkrd}ntd td }td }t|d}t|||d d S )Nl        r|  zsee gh-16456r  r  r  r  )sysmaxsizer  skiprY   r  r
   r  r2   r2   r3    test_pdist_correlation_iris_nonC  s   


z*TestPdist.test_pdist_correlation_iris_nonCrP  rQ  rR  r   r   皙	@c                 C   s<   d}t d }t|d|d}t|d|d}t||d|d d S )NrT  r  r#   rU  rV  r   )r   rI  r  )r  rP  rL  rZ  rM  rN  r2   r2   r3   test_pdist_minkowski_random_p  s
   z'TestPdist.test_pdist_minkowski_random_pc                 C   4   d}t d }t d }t|ddd}t|||d d S Nr|  r  pdist-minkowski-3.2r#   r  rU  r  r  r  r2   r2   r3   test_pdist_minkowski_random&  
   z%TestPdist.test_pdist_minkowski_randomc                 C   :   d}t td }td }t|ddd}t|||d d S r  r  r  r2   r2   r3   #test_pdist_minkowski_random_float32-  s
   z-TestPdist.test_pdist_minkowski_random_float32c                 C   r  )Nr|  r  r  rV  r  rU  r  r  r  r2   r2   r3    test_pdist_minkowski_random_nonC4  r  z*TestPdist.test_pdist_minkowski_random_nonCc                 C   r  )Nr|  r  pdist-minkowski-3.2-irisr#   r  rU  r  r  r  r2   r2   r3   test_pdist_minkowski_3_2_iris;  
   z'TestPdist.test_pdist_minkowski_3_2_irisc                 C   r  )Nr   r  r  r#   r  rU  r  r  r  r2   r2   r3   %test_pdist_minkowski_3_2_iris_float32C  s
   z/TestPdist.test_pdist_minkowski_3_2_iris_float32c                 C   r  )Nr|  r  r  rV  r  rU  r  r  r  r2   r2   r3   "test_pdist_minkowski_3_2_iris_nonCK  r  z,TestPdist.test_pdist_minkowski_3_2_iris_nonCc                 C   r  )Nr|  r  pdist-minkowski-5.8-irisr#   r'  rU  r  r  r  r2   r2   r3   test_pdist_minkowski_5_8_irisS  r  z'TestPdist.test_pdist_minkowski_5_8_irisc                 C   s@   d}t td }td }t|ddd}t|||tdkd d S )	Nr   r  r  r#   r'  rU  r   rH  r  r  r2   r2   r3   %test_pdist_minkowski_5_8_iris_float32[  s
   z/TestPdist.test_pdist_minkowski_5_8_iris_float32c                 C   r  )Nr|  r  r  rV  r'  rU  r  r  r  r2   r2   r3   "test_pdist_minkowski_5_8_iris_nonCc  r  z,TestPdist.test_pdist_minkowski_5_8_iris_nonCc                 C   s  t g ddd}t|dd}t|dt dt dt dt dt d	g t d
d
gdd
gd
dgdd
gd
dgg}t|dd}t d}t|||||dd| ddd| dg
 tt t	d
dgddggdd W d    d S 1 szw   Y  d S )N)r   r   r  r%  r   rn   r"   r  rb  rd  rc  r   r   r   r   r   )
rW   r   r   r   r
   re  r  r/  rz   r  )r  r   rh  ri  r2   r2   r3   test_pdist_mahalanobisk  s   (
&"z TestPdist.test_pdist_mahalanobisc                 C   r  NrD  rI   pdist-hammingr   r  r  r  r2   r2   r3   test_pdist_hamming_random|  r  z#TestPdist.test_pdist_hamming_randomc                 C   r  r"  r  r  r2   r2   r3   !test_pdist_hamming_random_float32  r  z+TestPdist.test_pdist_hamming_random_float32c                 C   r  NrD  rI   r#  test_hammingr  r  r  r2   r2   r3   test_pdist_hamming_random_nonC  r  z(TestPdist.test_pdist_hamming_random_nonCc                 C   r  r"  rW   r   rY   r  r
   r  r2   r2   r3   test_pdist_dhamming_random  r  z$TestPdist.test_pdist_dhamming_randomc                 C   r  r"  r  r  r2   r2   r3   "test_pdist_dhamming_random_float32  r  z,TestPdist.test_pdist_dhamming_random_float32c                 C   r  r&  r)  r  r2   r2   r3   test_pdist_dhamming_random_nonC  r  z)TestPdist.test_pdist_dhamming_random_nonCc                 C   r  )Ndy=r  pdist-jensenshannonr    r  r  r  r2   r2   r3   test_pdist_jensenshannon_random  r  z)TestPdist.test_pdist_jensenshannon_randomc                 C   r  )N:0yE>r  r.  r    r   rH  rW   r\   rY   r   r
   r   r  r2   r2   r3   'test_pdist_jensenshannon_random_float32  
   
z1TestPdist.test_pdist_jensenshannon_random_float32c                 C   r  )Nr-  r  r.  test_jensenshannonr  r  r  r2   r2   r3   $test_pdist_jensenshannon_random_nonC  r  z.TestPdist.test_pdist_jensenshannon_random_nonCc                 C   s<   t  rd}nd}td }td }t|d}t|||d d S )Ng&.=g-q=r  pdist-jensenshannon-irisr    r   )re   rY   r   r
   r  r2   r2   r3   test_pdist_jensenshannon_iris  s   
z'TestPdist.test_pdist_jensenshannon_irisc                 C   r  )Ngư>r  r6  r    r   r  r1  r  r2   r2   r3   %test_pdist_jensenshannon_iris_float32  r3  z/TestPdist.test_pdist_jensenshannon_iris_float32c                 C   r  )Ng-C6
?r  r6  r4  r  r  r  r2   r2   r3   "test_pdist_jensenshannon_iris_nonC  r  z,TestPdist.test_pdist_jensenshannon_iris_nonCc                 C   h   t tg dtg d}t tjg dtdtjg dtd}t|dddd t|dddd d S Nrn   r   rn   rn   r   rn   rn   r   rn   rn   rE   333333?r   绽|=rI  r   	wmatchingrW   r   r  r
   r  mm2r2   r2   r3   test_pdist_matching_mtica1     z$TestPdist.test_pdist_matching_mtica1c                 C   r:  Nrn   r   rn   rn   rn   r   rE   UUUUUU?r   r?  r@  rA  rC  r2   r2   r3   test_pdist_matching_mtica2  rG  z$TestPdist.test_pdist_matching_mtica2c                 C   x   t tg dtg d}t tjg dtdtjg dtd}tdkr*t| t|dddd t|dddd d S )Nr<  r=  rE   r   r   r?  r@  wyulerW   r   r  r   r  r
   rC  r2   r2   r3   test_pdist_yule_mtica1     z TestPdist.test_pdist_yule_mtica1c                 C   rM  )NrI  rJ  rE   r   r   r?  r@  rN  rC  r2   r2   r3   test_pdist_yule_mtica2  rQ  z TestPdist.test_pdist_yule_mtica2c                 C   x   t tg dtg d}t tjg dtdtjg dtd}tdkr*t| t|dddd t|dddd d S )	Nr<  r=  rE   r   g۶m۶m?r   r?  r@  wdicerW   r   r  r   r  r
   rC  r2   r2   r3   test_pdist_dice_mtica1  rQ  z TestPdist.test_pdist_dice_mtica1c                 C   rS  )	NrI  rJ  rE   r   rd  r   r?  r@  rT  rC  r2   r2   r3   test_pdist_dice_mtica2  rQ  z TestPdist.test_pdist_dice_mtica2c                 C   rS  	Nr<  r=  rE   r   g      ?r   r?  r@  )r(   rW   r   r  r   r  r
   rC  r2   r2   r3   test_pdist_sokalsneath_mtica1  rQ  z'TestPdist.test_pdist_sokalsneath_mtica1c                 C   rS  	NrI  rJ  rE   r   g?r   r?  r@  )wsokalsneathrW   r   r  r   r  r
   rC  r2   r2   r3   test_pdist_sokalsneath_mtica2  rQ  z'TestPdist.test_pdist_sokalsneath_mtica2c                 C   rS  rX  wrogerstanimotorW   r   r  r   r  r
   rC  r2   r2   r3    test_pdist_rogerstanimoto_mtica1#  rQ  z*TestPdist.test_pdist_rogerstanimoto_mtica1c                 C   rS  rZ  r]  rC  r2   r2   r3    test_pdist_rogerstanimoto_mtica2-  rQ  z*TestPdist.test_pdist_rogerstanimoto_mtica2c                 C   rS  )	Nr<  r=  rE   r   r>  r   r?  r@  wrussellraorW   r   r  r   r  r
   rC  r2   r2   r3   test_pdist_russellrao_mtica17  rQ  z&TestPdist.test_pdist_russellrao_mtica1c                 C   rS  )	NrI  rJ  rE   r   rK  r   r?  r@  ra  rC  r2   r2   r3   test_pdist_russellrao_mtica2A  rQ  z&TestPdist.test_pdist_russellrao_mtica2c                 C   sN   t d }tdkrt|j|j d}t|d}t|d}t|||tdkd d S )Nr  r   rD  r   test_canberrarH  )rY   r   r  r   rF   r  r
   )r  DrL  r  r  r2   r2   r3   test_pdist_canberra_matchK  s   

z#TestPdist.test_pdist_canberra_matchc                 C   s2   d}t dgdgfd}d}t|||tdkd d S )Nr0  r<  r   r   gd>@1?r   r  )r  r
   r   )r  rL  pdist_yrz  r2   r2   r3   test_pdist_canberra_ticket_711U  s   z(TestPdist.test_pdist_canberra_ticket_711c                    sZ   G dd d  fdd}t j  g  ggtd}t||d}d}t||tdkd	 d S )
Nc                   @   rk  )z6TestPdist.test_pdist_custom_notdouble.<locals>.myclassNrl  r2   r2   r2   r3   rm  _  rn  rm  c                    ro  rp  rr  rt  ru  r2   r3   r:  b  rv  z9TestPdist.test_pdist_custom_notdouble.<locals>._my_metricrE   r  rq  r   rw  )rW   r   rx  r   r   r   )r  r:  rH   rh  rz  r2   ru  r3   test_pdist_custom_notdouble]  s   z%TestPdist.test_pdist_custom_notdoubler|  c           
      K   s  z$t |fd|i|}t |fdt|i|}t |fdd| i|}W n ty } z|j}	tdkr<t|	j t| t|	 t |fd|i| W d    n1 sVw   Y  t|	 t |fdt|i| W d    n1 sww   Y  t|	 t |fdd| i| W d    n1 sw   Y  W Y d }~d S W Y d }~d S d }~ww t	|||tdkd t	|||tdkd d S r}  )
r   r0  r   r~  r   r  r   r  r/  r
   )
r  rZ  r4   rL  r   r  r  r  r   r  r2   r2   r3   r  k  s,   
8z$TestPdist._check_calling_conventionsc                 C   s   | j D ]f}t| d d dd d df }tdkrtd|d| |dv r'd|vr'q| || |dkrFtj|tjdd	d
}| j|||d q|dkrit	t
|tjj}ttj|j}| j|||d qd S )Nra  r   r  r  >   r   r*   matchingr%   r!   r(   r'   r$   r  r&   r   rn   r  r  r"   r  )r  rY   r   r  r  rW   r  r   r   r  r  r_  r   rY  r  )r  r4   r  rZ  r  r  r2   r2   r3   test_pdist_calling_conventions  s"   
z(TestPdist.test_pdist_calling_conventionsc                 C   sF  d}t d | jd ft d | jd ft d | jd ft d | jd	 fg}|D ]z}|d
 d d dd d df }zt||d}W nH ty } z<|j}tdkrVt|j t| |d D ]!}	|	|}
t	| t|
|d W d    n1 svw   Y  qZW Y d }~q&d }~ww |d D ]}	t|	||d}t
|||tdkd qq&d S )Nr|  rJ   r  rN   r  rM   r   rL   r\   r   ra  r   r  rn   rH  )rY   r  r   r   r~  r   r  r   r  r/  r
   )r  r4   rL  r  r  r1  r  r   r  r  r2  r  r2   r2   r3   test_pdist_dtype_equivalence  s:   

z&TestPdist.test_pdist_dtype_equivalencec              	   C   s  d}t d d d dd d df }t|jd |jd d  d }t }|dkr+d|d	< tj|tjd
}t| t||fi |}W d    n1 sKw   Y  t| t||fd|i|}W d    n1 sjw   Y  t	|||d t
||u  tj|d tjd
}	tt' t| t||fd|	i| W d    n1 sw   Y  W d    n1 sw   Y  tjd| tjd
d d d }
tt' t| t||fd|
i| W d    n1 sw   Y  W d    n1 sw   Y  tj|tjd
}tt1 t| t||fd|i| W d    n1 s&w   Y  W d    d S W d    d S 1 s?w   Y  d S )NrD  rL   ra  r   r   rn   r#   rS  rP  rE   r  r  r   )rY   r   r   r  rW   r  r   r  r   r
   r   r  r/  rz   r  )r  r4   rL  rZ  out_sizer   r  r  r  r  r  r  r2   r2   r3   test_pdist_out  sJ    




 $zTestPdist.test_pdist_outc                 C   s   d}t d d d dd d df }| }t|jj  t|jj t }|dkr,d|d< t| t||fi |}W d    n1 sDw   Y  t| t||fi |}W d    n1 saw   Y  t|||t	dkd d S )	NrD  rL   ra  r   r#   rS  rP  rH  )
rY   r  r   r  r  r  r  r   r
   r   )r  r4   rL  rZ  X_copyr   rM  rN  r2   r2   r3   r    s   

zTestPdist.test_stridingNr  )Xr   r  r  r  r  r  r  r  r  r  r  r  r  slowr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r	  r  r  rW   r  r  r  r  r  r  r  r  r  r  r   r!  r$  r%  r(  r*  r+  r,  r/  r2  r5  r7  r8  r9  rF  rL  rP  rR  rV  rW  rY  r\  r_  r`  rc  rd  rg  ri  rj  r  rl  rm  ro  r  r2   r2   r2   r3   r    s    	
#


		


	


	










		










	

'r  c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
ejjejdejdeegdd Zdd ZdS )TestSomeDistanceFunctionsc                 C   s,   t g d}t g d}||fg| _d S )Nr  r   r   r%  )rW   r   cases)r  r   r6  r2   r2   r3   r    s   z&TestSomeDistanceFunctions.setup_methodc           	      C   s   | j D ]4\}}t||dd}t|d t||dd}t|d t||dd}t|d t||dd}t|d	 qtd
dg}tddg}tt||t|d|d d S )Nrn   rU  r        ?gqaz@r   gw@rR  gR"6@i`  i  i^  i  uint16)rt  r#   r	   rW   r   r   r   )	r  r   r6  dist1dist1p5dist2dist0p25rj   r   r2   r2   r3   rV    s   



z(TestSomeDistanceFunctions.test_minkowskic                 C   s.   | j D ]\}}t||}t|td qd S )Nra  )rt  
weuclideanr	   rW   re  r  r   r6  rh  r2   r2   r3   rG    s   
z(TestSomeDistanceFunctions.test_euclideanc                 C   s(   | j D ]\}}t||}t|d qd S )Nr%  )rt  wsqeuclideanr	   r|  r2   r2   r3   test_sqeuclidean  s   
z*TestSomeDistanceFunctions.test_sqeuclideanc              	   C   s@   | j D ]\}}t||}t|ddtdtd    qd S )Nr   g      2@      )rt  wcosiner	   rW   re  r|  r2   r2   r3   r    s   
$z%TestSomeDistanceFunctions.test_cosinec                 C   s@   t tddgddgddtsJ t tddgddgtsJ d S )Nrn   F)centered)rs  wcorrelationfloatr  r  r2   r2   r3   test_cosine_output_dtype  s     z2TestSomeDistanceFunctions.test_cosine_output_dtypec                 C   s`   t g d}t g d}| jD ]\}}t||}t|dt ||t|t|    qd S )N)      r   r   )UUUUUUr  gUUUUUU@r   )rW   r   rt  r  r	   r^  r   )r  xmymr   r6  rh  r2   r2   r3   r  #  s   
(z*TestSomeDistanceFunctions.test_correlationc                 C   sT   t g d}t g d}t||}d|  kr%dt t jj ks(J  J d S )N)%rb  rb  rb  rb  rb  rb         rb  rb  rb  r  r  r  rb  r  rb  r  rb  rb  r  r  rb  r   rb  rb  r  rb  rb  r  rb  r  r  r  r  r  r  rb  )%r   r   r   r   r   r   r  r   r   r   r  r  r  r   r  r   r  r   r   rb  r  r   r   r   r   r  r   r   r  r   r  r  r  r  r  r  r   r   r  )rW   r   r   finfor   rL  r|  r2   r2   r3   test_correlation_positive*  s   
.z3TestSomeDistanceFunctions.test_correlation_positivezignore:Casting complexfuncc                 C   sL   ddg}ddg}t jdd ||| W d    d S 1 sw   Y  d S )Ny      ?        y       @        y      @        y      @        z"Complex `u` and `v` are deprecatedmatch)r  r  )r  r  r   r6  r2   r2   r3   test_corr_dep_complex5  s
   "z/TestSomeDistanceFunctions.test_corr_dep_complexc                 C   sh   t g d}t g d}t g dg dg dg}| jD ]\}}t|||}t|t d qd S )Nr  rs  )r   r   rb  )r   r   r   )rb  r   r   g      @)rW   r   rt  r"   r	   re  )r  r   r6  virh  r2   r2   r3   test_mahalanobis>  s   z*TestSomeDistanceFunctions.test_mahalanobisN)r   r  r  r  rV  rG  r~  r  r  r  r  r  r  r  filterwarningsr  r   r   r  r  r2   r2   r2   r3   rr    s    
rr  c                   @   sR   e Zd ZejejejejegZ	dd Z
dd Zdd Zdd Zd	d
 Zdd ZdS )TestSquareFormc                 C      | j D ]}| | qd S rq   )checked_dtypescheck_squareform_matrixr  rF   r2   r2   r3   test_squareform_matrixJ     
z%TestSquareForm.test_squareform_matrixc                 C   r  rq   )r  check_squareform_vectorr  r2   r2   r3   test_squareform_vectorN  r  z%TestSquareForm.test_squareform_vectorc                 C   s   t jd|d}t|}t|jd t|j| t jd|d}t|}t|jd t|j| t jddgddgg|d}t|}t|jd t|j| t|t jdg|d d S )N)r   r   rE   r   rn   rn   r   g@rm   )rW   zerosr   r   r   rF   r   r   )r  rF   ArAr2   r2   r3   r  R  s   z&TestSquareForm.check_squareform_matrixc                 C   s   t jd|d}t|}t|jd t|j| t|dgg t jdg|d}t|}t|jd t|j| t|t jddgddgg|d d S )Nr  rE   r  r   g @)r   r   )rW   r  r   r   r   rF   r   r   )r  rF   r  rvr2   r2   r3   r  c  s   $z&TestSquareForm.check_squareform_vectorc                 C      t ddD ]}| | qd S )Nr   ra  )r{   check_squareform_multi_matrixr  nr2   r2   r3   test_squareform_multi_matrixp     z+TestSquareForm.test_squareform_multi_matrixc           
      C   s   t j|d}t|}tt|jd t|}t|}|j}d}tdkr-t	|j|j|j tt|d tt|jd t|d |d  t
d|d D ]+}t
|d |d D ]}	||	krmt|||	f ||  |d7 }qWt|||	f d qWqLd S )N   rn   r   r   r   )rW   r   r   r  r   lenr   r   r   r  r{   )
r  r  rZ  Yr  Yrskr   jr2   r2   r3   r  t  s(   
z,TestSquareForm.check_squareform_multi_matrixN)r   r  r  rW   r   r\   int32int8r  r  r  r  r  r  r  r  r2   r2   r2   r3   r  G  s    r  c                   @   d   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd ZdS )TestNumObsYc                 C   s8   t ddD ]}tj|d}t|}tt|| qd S )Nr   r  r  )r{   rW   r   r   r  r   r   )r  r  rZ  r  r2   r2   r3   test_num_obs_y_multi_matrix  s
   z'TestNumObsY.test_num_obs_y_multi_matrixc                 C   s:   t t | d W d    d S 1 sw   Y  d S Nrn   )r  r/  rz   check_yr  r2   r2   r3   test_num_obs_y_1  s   "zTestNumObsY.test_num_obs_y_1c                 C      t | d d S Nr   r   r  r  r2   r2   r3   test_num_obs_y_2  s   zTestNumObsY.test_num_obs_y_2c                 C   r  )Nr   r  r  r2   r2   r3   test_num_obs_y_3     zTestNumObsY.test_num_obs_y_3c                 C   r  Nr  r  r  r2   r2   r3   test_num_obs_y_4  r  zTestNumObsY.test_num_obs_y_4c                 C   r  )Nra     )r{   minit)r  r   r2   r2   r3   test_num_obs_y_5_10  r  zTestNumObsY.test_num_obs_y_5_10c              	   C   |   t  }tddD ]}|||d  d  qtddD ] }||vr;tt | | W d    n1 s6w   Y  qd S Nr   r  rn   ra  i   setr{   addr  r/  rz   bad_yr  rj   r  r   r2   r2   r3   test_num_obs_y_2_100  s   z TestNumObsY.test_num_obs_y_2_100c                 C   s   t | | d S rq   r  r  r2   r2   r3   r    r  zTestNumObsY.minitc                 C   s   t j|}t|S rq   )rW   r   r   r   r  r  r6  r2   r2   r3   r    s   zTestNumObsY.bad_yc                 C      t | ||kS rq   )r   make_yr  r2   r2   r3   r    r  zTestNumObsY.check_yc                 C   s   t j||d  d S Nrn   r   rW   r   r   r  r2   r2   r3   r    r\  zTestNumObsY.make_yN)r   r  r  r  r  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r    s    r  c                   @   L   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )TestNumObsDMc                 C   sV   t ddD ]#}tj|d}t|}t|}tdkr!t|j|j t	t
|| qd S )Nrn   r  r  r   )r{   rW   r   r   r  r   r   r  r   r   r   )r  r  rZ  r  r  r2   r2   r3   test_num_obs_dm_multi_matrix  s   z)TestNumObsDM.test_num_obs_dm_multi_matrixc                 C   r  )Nr   r   check_Dr  r2   r2   r3   test_num_obs_dm_0     zTestNumObsDM.test_num_obs_dm_0c                 C   r  r  r  r  r2   r2   r3   test_num_obs_dm_1  r  zTestNumObsDM.test_num_obs_dm_1c                 C   r  r  r  r  r2   r2   r3   test_num_obs_dm_2  r  zTestNumObsDM.test_num_obs_dm_2c                 C   r  r  r  r  r2   r2   r3   test_num_obs_dm_3  r  zTestNumObsDM.test_num_obs_dm_3c                 C   r  r  r  r  r2   r2   r3   test_num_obs_dm_4  r  zTestNumObsDM.test_num_obs_dm_4c                 C   r  rq   )r   make_Dr  r2   r2   r3   r    r  zTestNumObsDM.check_Dc                 C   s   t j||S rq   r  r  r2   r2   r3   r    s   zTestNumObsDM.make_DN)r   r  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r    s    	r  c                 C      t | ddS NT)throw)r   )rf  r2   r2   r3   is_valid_dm_throw  r;  r  c                   @   st   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd ZdS )TestIsValidDMc                 C   H   t jdt jd}tt t| W d    d S 1 sw   Y  d S )Nra  rE   rW   r  r   r  r/  rz   r  r  rf  r2   r2   r3   $test_is_valid_dm_improper_shape_1D_E     
"z2TestIsValidDM.test_is_valid_dm_improper_shape_1D_Ec                 C   "   t jdt jd}tt|d d S )Nr  rE   FrW   r  r   r   r   r  r2   r2   r3   $test_is_valid_dm_improper_shape_1D_F     z2TestIsValidDM.test_is_valid_dm_improper_shape_1D_Fc                 C   r  Nr   r   r   rE   r  r  r2   r2   r3   $test_is_valid_dm_improper_shape_3D_E  r  z2TestIsValidDM.test_is_valid_dm_improper_shape_3D_Ec                 C   r  Nr  rE   Fr  r  r2   r2   r3   $test_is_valid_dm_improper_shape_3D_F  r  z2TestIsValidDM.test_is_valid_dm_improper_shape_3D_Fc                 C   sh   t jd}t|}tddD ]}d|||f< qtt t| W d    d S 1 s-w   Y  d S )Nr  r   ra  r   )	rW   r   r   r   r{   r  r/  rz   r  r  r6  rf  r   r2   r2   r3   #test_is_valid_dm_nonzero_diagonal_E  s   
"z1TestIsValidDM.test_is_valid_dm_nonzero_diagonal_Ec                 C   sB   t jd}t|}tddD ]}d|||f< qtt|d d S )Nr  r   ra  r   F)rW   r   r   r   r{   r   r   r  r2   r2   r3   #test_is_valid_dm_nonzero_diagonal_F  s
   z1TestIsValidDM.test_is_valid_dm_nonzero_diagonal_Fc                 C   s\   t jd}t|}|d d |d< tt t| W d    d S 1 s'w   Y  d S )Nr  r   rn   rn   rn   r   )rW   r   r   r   r  r/  rz   r  r  r6  rf  r2   r2   r3   test_is_valid_dm_asymmetric_E
  s   
"z+TestIsValidDM.test_is_valid_dm_asymmetric_Ec                 C   s6   t jd}t|}|d d |d< tt|d d S )Nr  r  rn   r  FrW   r   r   r   r   r   r  r2   r2   r3   test_is_valid_dm_asymmetric_F  s   z+TestIsValidDM.test_is_valid_dm_asymmetric_Fc                 C   r  )Nr  rE   Tr  r  r2   r2   r3   test_is_valid_dm_correct_1_by_1  r  z-TestIsValidDM.test_is_valid_dm_correct_1_by_1c                 C   &   t jd}t|}tt|d d S )Nrn   Tr  r  r2   r2   r3   test_is_valid_dm_correct_2_by_2     z-TestIsValidDM.test_is_valid_dm_correct_2_by_2c                 C   r  Nr   Tr  r  r2   r2   r3   test_is_valid_dm_correct_3_by_3   r  z-TestIsValidDM.test_is_valid_dm_correct_3_by_3c                 C   r  )N   Tr  r  r2   r2   r3   test_is_valid_dm_correct_4_by_4%  r  z-TestIsValidDM.test_is_valid_dm_correct_4_by_4c                 C   r  )Nr  Tr  r  r2   r2   r3   test_is_valid_dm_correct_5_by_5*  r  z-TestIsValidDM.test_is_valid_dm_correct_5_by_5N)r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r    s    r  c                 C   r  r  )r   )r6  r2   r2   r3   is_valid_y_throw0  r;  r  c                   @   r  )TestIsValidYc                 C   r  )Nr   r   rE   rW   r  r   r  r/  rz   r  r  r6  r2   r2   r3   #test_is_valid_y_improper_shape_2D_E9  r  z0TestIsValidY.test_is_valid_y_improper_shape_2D_Ec                 C   r  )Nr  rE   FrW   r  r   r   r   r  r2   r2   r3   #test_is_valid_y_improper_shape_2D_F>  r  z0TestIsValidY.test_is_valid_y_improper_shape_2D_Fc                 C   r  r  r  r  r2   r2   r3   #test_is_valid_y_improper_shape_3D_EB  r  z0TestIsValidY.test_is_valid_y_improper_shape_3D_Ec                 C   r  r  r	  r  r2   r2   r3   #test_is_valid_y_improper_shape_3D_FG  r  z0TestIsValidY.test_is_valid_y_improper_shape_3D_Fc                 C      |  d}tt|d d S )Nr   Tcorrect_n_by_nr   r   r  r2   r2   r3   test_is_valid_y_correct_2_by_2K     
z+TestIsValidY.test_is_valid_y_correct_2_by_2c                 C   r  r  r  r  r2   r2   r3   test_is_valid_y_correct_3_by_3O  r  z+TestIsValidY.test_is_valid_y_correct_3_by_3c                 C   r  )Nr  Tr  r  r2   r2   r3   test_is_valid_y_correct_4_by_4S  r  z+TestIsValidY.test_is_valid_y_correct_4_by_4c                 C   r  )Nra  Tr  r  r2   r2   r3   test_is_valid_y_correct_5_by_5W  r  z+TestIsValidY.test_is_valid_y_correct_5_by_5c              	   C   r  r  r  r  r2   r2   r3   test_is_valid_y_2_100[  s   z"TestIsValidY.test_is_valid_y_2_100c                 C   s   t j|}t|ddS r  )rW   r   r   r   r  r2   r2   r3   r  d  s   zTestIsValidY.bad_yc                 C   s   t j||d  d }|S r  r  r  r2   r2   r3   r  h  s   zTestIsValidY.correct_n_by_nN)r   r  r  r  r
  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r  4  s    	r  rP  )g      $g      rb  c                 C   s   t t tddgddg|  W d    n1 sw   Y  t t tddgddg| ddg W d    d S 1 s=w   Y  d S )Nrn   r   r   r  )r  r/  rz   r#   rU  r2   r2   r3   
test_bad_pm  s   "r  c                   C   sB   t t tg dg d W d    d S 1 sw   Y  d S )N)FFF)r  r/  rz   r(   r2   r2   r2   r3   test_sokalsneath_all_falsev  s   "r  c                   C   s4   t tg dg dd t tg dg dd d S )Nrn   r   r   r   r  r   rn   rn   rn   r   r   rn   r   rn   r   r   )r   	wcanberrar2   r2   r2   r3   re  |  s   re  c                   C   s<   t tg dg dddd t tg dg dddd d S )	Nr  r  UUUUUU?   decimalr  r  rd  )r	   wbraycurtisr2   r2   r2   r3   test_braycurtis  s    r"  c                  C   s  t g d} t g d}tt| |ddd tt| |t ddd tjtdd  t| t j	d d f |t j	d d f t df W d    n1 sOw   Y  tjtdd t| t j	d d f |t j	d d f  W d    n1 syw   Y  tjtdd t| d d t j	f |d d t j	f  W d    n1 sw   Y  t 
d	d
d
}tt t|| W d    n1 sw   Y  tt t|| W d    n1 sw   Y  t jd}|d}|d}t||}t||}t|d
 |dd d S )N)rn   rn   rn   r   r   r   r  r  r  r   Input vector should be 1-Dr  r  r   iIr  )rW   r   r	   r}  r{  re  r  r/  rz   newaxisr.  r   r   r   r   )rf  rg  r   rsr6  d1d2r2   r2   r3   test_euclideans  s4   2((



r)  c                  C   sJ   g d} g d}t t t| | W d    d S 1 sw   Y  d S )Nr   r   rn   r  r  r/  rz   whammingrt  r2   r2   r3   test_hamming_unequal_length  s
   "r-  c                  C   s\   g d} g d}g d}d}t jt|d t| || W d    d S 1 s'w   Y  d S )Nr*  r  z/'w' should have the same length as 'u' and 'v'.r  r+  )ur  r   r  r2   r2   r3   "test_hamming_unequal_length_with_w  s   "r/  c                  C   s<   t jg ddd} t jg ddd}d}tt| || d S )N)eggsspamr1  r0  r1  r1  r1  r1  r1  r1  r1  r0  r0  r1  r0  r0  r0  r0  r0  r1  z|S4rE   )r0  r1  r1  r0  r0  r1  r1  r1  r1  r0  r1  r0  r1  r0  r1  r1  r0  r1  r1  r0  g?)rW   r   r
   r,  )rj   r   desiredr2   r2   r3   test_hamming_string_array  s   

r3  c                  C   sv   t g dg dg} t| ddd d}t| | ddd d}t| ddd}t| | ddd}t||dd t||dd d S )N)
QUUT@      Y@r4  r5  g      B@g      N@g     V@g     b@g      8@g      H@r#   rn   )r4   rP  r   )r4   rP  rD  r  )rW   r   r   r   r
   )arr_inp0c0p1c1r2   r2   r3   test_minkowski_w  s   
r;  c                  C   s@  g d} g d}t jt jt jt jfD ]}tt j| |dt j||d}tt |j	t j
 qt jt jt jt jfD ]/}t |j}tdgt j|g|d}tt j|g|ddg}t|| t|t |d  q8t jt jt jt jg}dD ]}tt |r|tt | qt|D ]}tt j| |dt j||d}t|j	| qd S )Nr  )r  ra  r   rE   r   r   )float16float128)rW   r  int16r  r  r}  asarrayr   r   rF   floatinguint8rv  uint32uint64iinfomaxr   r   r\   	complex64
complex128hasattrr   getattr)r   r6  rF   dumaxr'  r(  dtypesr2   r2   r3   test_sqeuclidean_dtypes  s(   

rM  c                  C   s   g d} g d}dd | D }dd |D }t   t| |}W d    n1 s*w   Y  t   t||}W d    n1 sCw   Y  t|| d S )N)TTF)TFTc                 S      g | ]}t |qS r2   r   ri   r   r2   r2   r3   rk         z&test_sokalmichener.<locals>.<listcomp>c                 S   rN  r2   rO  rP  r2   r2   r3   rk     rQ  )r  r  r'   r   )rP  r   r   r6  rw  ry  r2   r2   r3   test_sokalmichener  s   

rR  c            	   	   C   s   d} d}d}d}d||   || d||     }t |d t  tddgddgddgd}W d    n1 s9w   Y  t || g d	}g d
}dD ] }t  t t|||gd W d    n1 shw   Y  qMd S )Nrb  g?r   r   gX$I?rn   r   r   )FFTTTFFTTTTTTFTFFFTT)TTTFFTTTFTTTTTFFFTTT)g?rQ  r   g      4@rK  )r	   r  r  r'   )	ntfnftnttnffexpectedactuala1a2r   r2   r2   r3   test_sokalmichener_with_weight  s$    



r\  c                 C   s   t g dg dg dg dg}| }t|  t|||  W d    n1 s*w   Y  t|  t||  W d    n1 sCw   Y  t|| d S )Nr  r  r!  g3333336@gL7@g333333F@)rW   r?  r  r  r   r   r   )r4   r1  r  r2   r2   r3   test_modifies_input  s   


r^  c              
   C   s  t g dg dg dg dg}tt t||| d W d    n1 s(w   Y  tt t|| d W d    n1 sCw   Y  dD ]}|di}|dkrX| d	ksh|d
kr`| dksh|dkri| dkriqJtt& t|  t||| fi | W d    n1 sw   Y  W d    n1 sw   Y  tt% t|  t|| fi | W d    n1 sw   Y  W d    n1 sw   Y  qJd S )Nr  r  r!  r]  r   )rP  r  r  foor  r&   r  r"   rP  r#   )rW   r?  r  r/  r   r   r   r  )r4   r1  r7  r   r2   r2   r3   test_Xdist_deprecated_args.  s>   


r`  c              
   C   s6  t d d d dd d df }t|jd }|d d d  |d d d< | dv r,td | t| d|  fD ]c}tt# t	|  t
|||d W d    n1 sSw   Y  W d    n1 sbw   Y  tt$ t	|  t||||d W d    n1 sw   Y  W d    n1 sw   Y  q5d S )	NrL   ra  r   rn   )r&   r"   r    not applicabler-  rS  )rY   rW   r   r   r  r  r0  r/  rz   r  r   r   )r4   rZ  r   rD  r2   r2   r3   test_Xdist_non_negative_weightsM  s(   


rb  c                  C   s4  g d} t | }t||  t | tjd}t||  t|jtj dg} t | }t|jd t||  d} tjt	dd t |  W d    n1 sJw   Y  t
dddd} tjt	dd t |  W d    n1 sow   Y  ddgd	d
gg} tjt	dd t |  W d    d S 1 sw   Y  d S )Nr  rE   rn   r$  r  ra  r   r   r   r  )r   r   rW   r   r   rF   ro   r  r/  rz   r.  r   rt  r2   r2   r3   test__validate_vector_  s,   





"rc  c                  C   sp   t jdtd} t| d | d }|dksJ t| d}t|dg t| d d | d d d}t|dgg d S )N)r   r   rE   r   rb  r*   rn   )rW   r   r  rO  r   r   r   )r   rJ  r2   r2   r3   test_yule_all_samey  s   
rd  c                  C   sJ  t tg dg ddd t tddgddgd t tg dg dd t tddggddggd	d
ddg t tddggddggdd
dg t tddggddggd	ddddgg t tddggddggddddgg tg dg dg dg} tg dg dg dg}t t| |d	d
g d t t| |dd
g d d S )N)r   rb  rb  )rb  r   rb  r   r   rb  rd  g)>d?ru  r   r~   rn   gД?T)r|   keepdims)rn   r   r   r  )ra  r      rb   )	   r        )   r  r  r  )            )            )g'Y?gTyCЇ?gFw$?g\BZ?)g;0%7/?g)o?gku?)r	   r    rW   r   )rj   r   r2   r2   r3   r4    sJ   

r4  c                  C   sh   t g d} t g d}t| |}t| |gdd}t|| tt | t |dd}t|| d S )N)rn   r   r   )r   r   r   r   r  )rW   r   r   r   r
   r   r  )arr_1arr_2rX  rY  r2   r2   r3   test_gh_17703  s   



ru  c                 C   st   | dv r	t d tjdtjd}|jdd t|  ttj	j
| |||d W d    d S 1 s3w   Y  d S )N)r    r"   r&   ra  r  rE   F)writerS  )r  r  rW   r.  r   setflagsr  rI  scipyspatialdistance)r4   r   r2   r2   r3   test_immutable_input  s   

"r{  c                   @   r  )TestJaccardc                 C   r  Nr0  rI   pdist-jaccardr   r  r  r  r2   r2   r3   test_pdist_jaccard_random  r  z%TestJaccard.test_pdist_jaccard_randomc                 C   r  r}  r  r  r2   r2   r3   !test_pdist_jaccard_random_float32  r  z-TestJaccard.test_pdist_jaccard_random_float32c                 C   r  Nr0  rI   r~  test_jaccardr  r  r  r2   r2   r3   test_pdist_jaccard_random_nonC  r  z*TestJaccard.test_pdist_jaccard_random_nonCc                 C   r  r}  r)  r  r2   r2   r3   test_pdist_djaccard_random  r  z&TestJaccard.test_pdist_djaccard_randomc                 C   r  r}  r  r  r2   r2   r3   "test_pdist_djaccard_random_float32  r  z.TestJaccard.test_pdist_djaccard_random_float32c                 C   ,   d}t tdd}ttd||d d S )NrD  ra  r   r   r  r  r   rW   r  r
   r  rL  r  r2   r2   r3   test_pdist_djaccard_allzeros     z(TestJaccard.test_pdist_djaccard_allzerosc                 C   r  r  r)  r  r2   r2   r3   test_pdist_djaccard_random_nonC  r  z+TestJaccard.test_pdist_djaccard_random_nonCc                 C   r  )NrD  r  r  r  r  r  r  r2   r2   r3   !test_pdist_djaccard_allzeros_nonC  r  z-TestJaccard.test_pdist_djaccard_allzeros_nonCc                 C   r:  r;  wjaccardrW   r   r  r
   rC  r2   r2   r3   test_pdist_jaccard_mtica1     z%TestJaccard.test_pdist_jaccard_mtica1c                 C   r:  rH  r  rC  r2   r2   r3   test_pdist_jaccard_mtica2  r  z%TestJaccard.test_pdist_jaccard_mtica2c                 C   sp   t g d}t g d}t tj}tt||d|d tt|g|gddgg tt||gddg d S )N)ig      @r   )r   r   r  r  r   )	rW   r   r  r  rL  r
   r   r   r   )r  r   r6  rL  r2   r2   r3   test_non_01_input  s   zTestJaccard.test_non_01_inputN)r   r  r  r  r  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r|    s    r|  c                   @   r  )TestChebyshevc                 C   r  )Nr0  r  pdist-chebyshevr   r  r  r  r2   r2   r3   test_pdist_chebyshev_random	  r  z)TestChebyshev.test_pdist_chebyshev_randomc                 C   r  )Nr|  r  r  r   r   rH  r1  r  r2   r2   r3   #test_pdist_chebyshev_random_float32	  r3  z1TestChebyshev.test_pdist_chebyshev_random_float32c                 C   r  )Nr0  r  r  test_chebyshevr  r  r  r2   r2   r3    test_pdist_chebyshev_random_nonC	  r  z.TestChebyshev.test_pdist_chebyshev_random_nonCc                 C   r  )NrX  r  pdist-chebyshev-irisr   r  r  r  r2   r2   r3   test_pdist_chebyshev_iris 	  r  z'TestChebyshev.test_pdist_chebyshev_irisc                 C   r  )Nr   r  r  r   r   rH  r1  r  r2   r2   r3   !test_pdist_chebyshev_iris_float32'	  r3  z/TestChebyshev.test_pdist_chebyshev_iris_float32c                 C   r  )NrX  r  r  r  r  r  r  r2   r2   r3   test_pdist_chebyshev_iris_nonC.	  r  z,TestChebyshev.test_pdist_chebyshev_iris_nonCc                 C   f   g d}g d}g d}t t|||d t t||gd|ddg t t|g|gd|ddgg d S )Nr  r   ra  r  )r   rn   ra  r   r   rS  r   r   r   r   r  r   r6  r   r2   r2   r3   test_weighted5	  s   "zTestChebyshev.test_weightedc                 C   r  )Nr  r  r#  r   r   rS  r  r  r2   r2   r3   test_zero_weight?	  s   "zTestChebyshev.test_zero_weightN)r   r  r  r  r  r  r  r  r  r  r  r2   r2   r2   r3   r  		  s    
r  rq   )	NNFTFFFFN)r
  os.pathrQ   	functoolsr   r   r  numpyrW   r   numpy.linalgr   numpy.testingr   r   r   r   r	   r
   r   r   r  scipy.spatial.distancerx  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   scipy._lib._utilr+   r,   fixturer4   rO   r   _tdist_ytdistrY   ra   re   r}   r   r   r   r   assert_allclose_forgivingr   r  r  strr  r]  rK  r  r  r^  rB  r,  rO  rU  
wcityblock
wchebyshevr  r  wkulczynski1r  r{  r}  r!  r  r[  wsokalmichenerrb  r  r  rr  r  r  r  r  r  r  r  r  r  r  r  re  r"  r)  r-  r/  r3  r;  rM  r  rR  r\  r^  r`  rb  rc  rd  r4  ru  r{  r|  r  r2   r2   r2   r3   <module>   s   "(,\

 

0	


f  9      TC6#I9
!		





	Q