o
    iTW                    @   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   [/home/kim/smarthome/.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npZloadtxteocloseZbool_float32r+   r,   )fnnameZfqfnfpr2   r2   r3   load_testing_files{   s   
r^   c                   C   s   t djdk S )Nr      )rW   Zintpitemsizer2   r2   r2   r3   	_is_32bit   s   ra   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   Zravelrd   r2   r2   r3   rg      s    r   c                 s   s    | ]}t |V  qd S N)rW   
atleast_1drd   r2   r2   r3   	<genexpr>       z _chk_asarrays.<locals>.<genexpr>c                 3   s     | ]}|j  d  j kV  qdS )r   N)rk   rd   arraysr2   r3   rn          z(array ndim must be the same for neg axis)tupleall
ValueErrorrangerk   )rq   axisr2   rp   r3   _chk_asarrays   s   
rx   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rw   c                 s   s$    | ]}t j|t jjuV  qd S rl   )rW   magetmasknomaskrd   r2   r2   r3   rn      s   " z_chk_weights.<locals>.<genexpr>c                 S   s   g | ]
}t t |qS r2   )rW   isnansumrd   r2   r2   r3   rg          z _chk_weights.<locals>.<listcomp>Tc                 s   s(    | ]\}}|rt j|n|V  qd S rl   rW   r{   Zmasked_invalid)re   rf   Zhas_nanr2   r2   r3   rn      s    r   c                 3   s"    | ]}j |j   fkV  qd S rl   shaperd   )rw   weightsr2   r3   rn      s     z*weights shape must match arrays along axiszweights cannot be negativec                 3   s     | ]}t j| d V  qdS )ry   N)rW   takerd   )rw   pos_weightsr2   r3   rn      rr   rj   )rx   anyrs   ziprW   rc   onesr   _freq_weights_weight_maskedrt   ru   Znonzerosize)rq   r   rw   force_weightsZsimplify_weightsZpos_onlyZ	neg_checkZ
nan_screenmask_screenddofchkedZhas_nansr2   )rw   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   ru   )r   Z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   rj   c                 3   s    | ]	}| kr|V  qd S rl   r2   re   iry   r2   r3   rn      s    z!_weight_masked.<locals>.<genexpr>ry   )rW   rc   r{   r|   r}   rk   rs   rv   r   r   r   )rq   r   rw   rf   Z	axis_maskZnot_axesr2   ry   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)re   Zarrr2   r2   r3   rg      s
    z_rand_split.<locals>.<listcomp>rE   c                    s6   t t j |d}| fddt jD S )Nry   c                    s"   g | ]}|kr j | nd qS ri   r   r   rf   rw   r2   r3   rg      s    z/_rand_split.<locals>.mytake.<locals>.<listcomp>)rW   rc   r   reshaperv   rk   )rf   Zixrw   recordr2   r   r3   mytake   s   z_rand_split.<locals>.mytaker   c                 3   s    | ]
}|j   kV  qd S rl   r   rd   )rw   n_obsr2   r3   rn      s    z_rand_split.<locals>.<genexpr>z#data must be aligned on sample axis      ?c              	      s&   g | ]}t j|| d  d qS ry   rW   appendrd   )rw   r   split_ixr2   r3   rg      s
    
)rW   arrayr   randomRandomStater   rt   rv   r   randintrandr   )	rq   r   rw   	split_perseedZseeded_randr   Zprev_wqr2   )rw   r   r   r   r3   _rand_split   s(   r   h㈵>atolc                 C      | S rl   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	TypeErrorru   r   _rough_check)	rf   br   keywZcheck_aZcheck_bZa_iZb_ir2   r2   r3   r     s   r      c                 C   r   rl   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 )Nrw   T)r   rw   r   r   rz   c                 S   s   g | ]	}t | qS r2   )rW   rm   squeezerd   r2   r2   r3   rg   +  s    z4_weight_checked.<locals>.wrapped.<locals>.<listcomp>)r   g     @Y@gB`"۹?)r   r   r   e   Z
nan_policyZomitc                 S   s   g | ]}t j|qS r2   r   rd   r2   r2   r3   rg   Y  s    c                    s   g | ]
}t j|| d qS r   r   rd   ry   r2   r3   rg   c  r          @z NotImplemented weights:    )
stacklevel)getr   rs   r   	Exceptiontyper   r   slicerk   rW   nanr   NotImplementedErrorwarningswarn__name__)argskwargsresultrq   restr   r   eZ
dud_arraysZdud_weightsZdud_argsrf   ZindexerZ
dup_arraysZdup_weightsZdup_argssplitZsplit_arraysZsplit_weightsZ
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_argry   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 rl   r2   selfr2   r2   r3   	__enter__}     zDummyContextManager.__enter__c                 G   r   rl   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   rj   )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   rZ   rnd_eo_namesr,   r+   rW   rZ   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   Z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 )Nrj   r   c                 S      || | S rl   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
@r  r  r  皙?r4   r  r  皙@rj   r   )rW   r	  r   r
  r   r   r
   )r   r  r  r  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   rX   wcdist_no_constr
   r   )r   epsr  r  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%<=r   r!  r#   r+  test_minkowskir   r   )r   r$  r   r%  )r   r+  r'  r  r  r(  r)  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+=r   r!  r   c                 S   s   t jj| ddddS )Nrj   ry   rz   )rW   linalgr   r   )Xr2   r2   r3   norms     z1TestCdist.test_cdist_cosine_random.<locals>.normsrj   r   r#  )rX   wcdistrW   dotTr
   r   )r   r'  r  r  r(  r6  r)  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   rz   rj   r   )rW   r   r   r
   sqrtr   r
  ru   )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      rH  c                    (   t | d  rt |d  stddS Nr   zType has been changed+?
isinstanceru   r   r  rH  r2   r3   r  !     z9TestCdist.test_cdist_custom_notdouble.<locals>._my_metricrE   r   rL  r   r   )rW   r   objectr   r   r   )r   r  rH   Zcdist_yright_yr2   rP  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   r#  )
r   r  r   	__class__r   printr   r   r
  r
   )r   r  r  r4   r'  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 )Nr<  r   rj   r   	testing:  with: >   r'   r!   r*   r$   r(   r%   r   r   r&   r   rw   r   Vr"   VI)r   rX   r   rY  r^  rW   vstackr   r   var
atleast_2dcovr:  r   r4  inv)r   r4   eo_namer  r  ZX12rc  re  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 )NrV  rJ   r   rN   r   rM   r   rL   rZ   r   r<  r   rj   r   r   r#  )rX   r   r   r   rX  r   rY  r   r   r
  r
   )r   r4   r'  teststestr  r  rZ  r   r]  new_typeZX1newZ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 )Nr  r   r!  r   r#   r.  r+  rE   outr   r#  rj   F)rF   order)rX   r   dictrW   emptyr   r   r   r
   r   r   r   r
  ru   int64)r   r4   r'  r  r  Zout_rZout_cr   out1r(  r)  out2out3Z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 )	Nr  r   r   r!  r#   r.  r+  r#  )rX   copyr   r   flagsc_contiguousrt  r   r   r
   r   )
r   r4   r'  r  r  X1_copyZX2_copyr   r(  r)  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#   r.  r+  r4   c                 S   rb   r2   )weakrefref)re   vr2   r2   r3   rg     rh   z1TestCdist.test_cdist_refcount.<locals>.<listcomp>c                 s   s    | ]}| d u V  qd S rl   r2   )re   Zweak_refr2   r2   r3   rn     ro   z0TestCdist.test_cdist_refcount.<locals>.<genexpr>)	rW   r   r   rt  r   r   r   r   rt   )r   r4   rA  rB  r   rq  Z	weak_refsr2   r2   r3   test_cdist_refcount  s   
zTestCdist.test_cdist_refcountNrV  )r   r   r   r   r   markthread_unsafer  r  r*  parametrizerW   infr2  r;  rE  rU  r^  rl  rp  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   r  )r   r4   r  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 )Nrj   r   c                 S   r  rl   r2   r  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  r  r  )rW   r	  r   r
  r   r   r
   )r   r  r  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 NrV  pdist-double-inppdist-euclideanr   r$  rX   wpdist_no_constr
   r   r'  r5  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   rZ   rX   r  r
   r  r2   r2   r3   #test_pdist_euclidean_random_float32-  
   
z-TestPdist.test_pdist_euclidean_random_float32c                 C   r  )NrV  r  r  r"  r  r  r   r'  r5  r  Y_test2r2   r2   r3    test_pdist_euclidean_random_nonC4  r  z*TestPdist.test_pdist_euclidean_random_nonCc                 C   r  )NrV  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   r#  rW   rZ   rX   r  r
   r   r  r2   r2   r3   !test_pdist_euclidean_iris_float32C  
   
z+TestPdist.test_pdist_euclidean_iris_float32c                 C   r  )NrV  r  r  r"  r  r  r  r2   r2   r3   test_pdist_euclidean_iris_nonCK  
   
z(TestPdist.test_pdist_euclidean_iris_nonCc                 C   r  )NrV  r  pdist-seuclideanr&   r  rX   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 )
NrV  r  r  r&   r  r   rj   ra  rb  )rW   rZ   rX   r   r
   rg  )r   r'  r5  r  r  rc  r  r2   r2   r3   $test_pdist_seuclidean_random_float32\  s   
z.TestPdist.test_pdist_seuclidean_random_float32c                 C   r  )NrV  r  r  test_seuclideanr  r  r  r2   r2   r3   !test_pdist_seuclidean_random_nonCh  r  z+TestPdist.test_pdist_seuclidean_random_nonCc                 C   r  )NrV  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   rZ   rX   r   r
   r  r2   r2   r3   "test_pdist_seuclidean_iris_float32w  s
   
z,TestPdist.test_pdist_seuclidean_iris_float32c                 C   r  )NrV  r  r  r  r  r  r  r2   r2   r3   test_pdist_seuclidean_iris_nonC  s
   
z)TestPdist.test_pdist_seuclidean_iris_nonCc                 C   r  NrV  r  pdist-cosiner   r  rX   wpdistr
   r  r2   r2   r3   test_pdist_cosine_random  r  z"TestPdist.test_pdist_cosine_randomc                 C   r  r  rW   rZ   rX   r  r
   r  r2   r2   r3    test_pdist_cosine_random_float32  r  z*TestPdist.test_pdist_cosine_random_float32c                 C   r  )NrV  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   rZ   rX   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   rf  r   r  )r   r   r5  r2   r2   r3   test_pdist_cosine_bounds  s
   
z"TestPdist.test_pdist_cosine_boundsc                 C   r  NrV  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  )NrV  r  r  test_cityblockr  r  r  r2   r2   r3    test_pdist_cityblock_random_nonC  r  z*TestPdist.test_pdist_cityblock_random_nonCc                 C   r  )Nr3  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   r#  r  r  r2   r2   r3   !test_pdist_cityblock_iris_float32  r  z+TestPdist.test_pdist_cityblock_iris_float32c                 C   r  )Nr3  r  r  r  r  r  r  r2   r2   r3   test_pdist_cityblock_iris_nonC  r  z(TestPdist.test_pdist_cityblock_iris_nonCc                 C   r  NrV  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  )NrV  r  r  test_correlationr  r  r  r2   r2   r3   "test_pdist_correlation_random_nonC  r  z,TestPdist.test_pdist_correlation_random_nonCc                 C   r  )NrV  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 )NrV  r  r  r   r   r#  )rX   rW   rZ   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        rV  zsee gh-16456r  r  r  r  )sysmaxsizer   skiprX   r  r
   r  r2   r2   r3    test_pdist_correlation_iris_nonC  s   


z*TestPdist.test_pdist_correlation_iris_nonCr+  r,  r-  r   r   皙	@c                 C   s<   d}t d }t|d|d}t|d|d}t||d|d d S )Nr/  r  r#   r0  r1  r   )r   r$  r  )r   r+  r'  r5  r(  r)  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 NrV  r  pdist-minkowski-3.2r#   r  r0  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  )NrV  r  r  r1  r  r0  r  r  r  r2   r2   r3    test_pdist_minkowski_random_nonC4  r  z*TestPdist.test_pdist_minkowski_random_nonCc                 C   r  )NrV  r  pdist-minkowski-3.2-irisr#   r  r0  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  r0  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  )NrV  r  r  r1  r  r0  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  )NrV  r  pdist-minkowski-5.8-irisr#   r  r0  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  r0  r   r#  r  r  r2   r2   r3   %test_pdist_minkowski_5_8_iris_float32[  s
   z/TestPdist.test_pdist_minkowski_5_8_iris_float32c                 C   r  )NrV  r  r  r1  r  r0  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  rz   rj   r"   r   r=  r?  r>  r   r   r   r   r   )
rW   r   r   r   r
   r@  r   r
  ru   r  )r   r   rC  rD  r2   r2   r3   test_pdist_mahalanobisk  s   (
&"z TestPdist.test_pdist_mahalanobisc                 C   r  Nr  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  Nr  rI   r  Z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   rX   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   r#  rW   rZ   rX   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   )ra   rX   r   r
   r  r2   r2   r3   test_pdist_jensenshannon_iris  s   
z'TestPdist.test_pdist_jensenshannon_irisc                 C   r  )Ngư>r  r  r    r   r  r  r  r2   r2   r3   %test_pdist_jensenshannon_iris_float32  r  z/TestPdist.test_pdist_jensenshannon_iris_float32c                 C   r  )Ng-C6
?r  r  r  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rj   r   rj   rj   r   rj   rj   r   rj   rj   rE   333333?r   绽|=r$  r   	wmatchingrW   r   r   r
   r   mm2r2   r2   r3   test_pdist_matching_mtica1     z$TestPdist.test_pdist_matching_mtica1c                 C   r
  Nrj   r   rj   rj   rj   r   rE   UUUUUU?r   r  r  r  r  r2   r2   r3   test_pdist_matching_mtica2  r  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   rY  r
   r  r2   r2   r3   test_pdist_yule_mtica1     z TestPdist.test_pdist_yule_mtica1c                 C   r  )Nr  r  rE   r   r   r  r  r  r  r2   r2   r3   test_pdist_yule_mtica2  r!  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   rY  r
   r  r2   r2   r3   test_pdist_dice_mtica1  r!  z TestPdist.test_pdist_dice_mtica1c                 C   r#  )	Nr  r  rE   r   r?  r   r  r  r$  r  r2   r2   r3   test_pdist_dice_mtica2  r!  z TestPdist.test_pdist_dice_mtica2c                 C   r#  	Nr  r  rE   r   g      ?r   r  r  )r(   rW   r   r   r   rY  r
   r  r2   r2   r3   test_pdist_sokalsneath_mtica1  r!  z'TestPdist.test_pdist_sokalsneath_mtica1c                 C   r#  	Nr  r  rE   r   g?r   r  r  )wsokalsneathrW   r   r   r   rY  r
   r  r2   r2   r3   test_pdist_sokalsneath_mtica2  r!  z'TestPdist.test_pdist_sokalsneath_mtica2c                 C   r#  r(  wrogerstanimotorW   r   r   r   rY  r
   r  r2   r2   r3    test_pdist_rogerstanimoto_mtica1#  r!  z*TestPdist.test_pdist_rogerstanimoto_mtica1c                 C   r#  r*  r-  r  r2   r2   r3    test_pdist_rogerstanimoto_mtica2-  r!  z*TestPdist.test_pdist_rogerstanimoto_mtica2c                 C   r#  )	Nr  r  rE   r   r  r   r  r  wrussellraorW   r   r   r   rY  r
   r  r2   r2   r3   test_pdist_russellrao_mtica17  r!  z&TestPdist.test_pdist_russellrao_mtica1c                 C   r#  )	Nr  r  rE   r   r  r   r  r  r1  r  r2   r2   r3   test_pdist_russellrao_mtica2A  r!  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   r  r   test_canberrar#  )rX   r   rY  r   rF   r  r
   )r   Dr'  rZ  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 )Nr   r  r   r   gd>@1?r   r  )r  r
   r   )r   r'  pdist_yrT  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                   @   rF  )z6TestPdist.test_pdist_custom_notdouble.<locals>.myclassNrG  r2   r2   r2   r3   rH  _  rI  rH  c                    rJ  rK  rM  rO  rP  r2   r3   r  b  rQ  z9TestPdist.test_pdist_custom_notdouble.<locals>._my_metricrE   r   rL  r   rR  )rW   r   rS  r   r   r   )r   r  rH   r8  rT  r2   rP  r3   test_pdist_custom_notdouble]  s   z%TestPdist.test_pdist_custom_notdoublerV  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 rW  )
r   r  r   rX  r   rY  r   r   r
  r
   )
r   r5  r4   r'  r   rZ  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 )Nr<  r   r_  r`  >   r'   Zmatchingr!   r*   r$   r(   r%   r   r   r&   r   rj   ra  rb  r"   rd  )r   rX   r   rY  r^  rW   rg  r   r   rh  ri  r:  r   r4  rj  )r   r4   rk  r5  rc  re  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 )NrV  rJ   r   rN   r   rM   r   rL   rZ   r   r<  r   r   rj   r#  )rX   r   r   r   rX  r   rY  r   r   r
  r
   )r   r4   r'  rm  rn  r  rZ  r   r]  ro  r  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 )Nr  rL   r<  r   r   rj   r#   r.  r+  rE   rq  r  r   )rX   r   r   rt  rW   ru  r   r   r   r
   r   r   r
  ru   rv  )r   r4   r'  r5  Zout_sizer   rw  r  r  rx  ry  rz  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 )	Nr  rL   r<  r   r#   r.  r+  r#  )
rX   r|  r   r}  r~  rt  r   r   r
   r   )r   r4   r'  r5  ZX_copyr   r(  r)  r2   r2   r3   r    s   

zTestPdist.test_stridingNr  )Xr   r   r   r   r   r  r  r  r  r  r  r  r  Z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  r  r  r  r  r	  r  r  r   r"  r&  r'  r)  r,  r/  r0  r3  r4  r7  r9  r:  r^  r;  r<  r=  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   r  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 )Nrj   r0  r         ?gqaz@r   gw@r-  gR"6@i`  i  i^  i  uint16)r@  r#   r	   rW   r   r   r   )	r   r   r  dist1Zdist1p5dist2Zdist0p25rf   r   r2   r2   r3   r1    s   



z(TestSomeDistanceFunctions.test_minkowskic                 C   s.   | j D ]\}}t||}t|td qd S )Nr<  )r@  
weuclideanr	   rW   r@  r   r   r  rC  r2   r2   r3   r"    s   
z(TestSomeDistanceFunctions.test_euclideanc                 C   s(   | j D ]\}}t||}t|d qd S )Nr  )r@  wsqeuclideanr	   rF  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@      )r@  wcosiner	   rW   r@  rF  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 )Nrj   F)Zcentered)rN  wcorrelationfloatrK  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   )UUUUUUrP  gUUUUUU@r   )rW   r   r@  rL  r	   r9  r   )r   ZxmZymr   r  rC  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)%r=  r=  r=  r=  r=  r=         r=  r=  r=  rQ  rQ  rQ  r=  rQ  r=  rQ  r=  r=  rO  rQ  r=  r   r=  r=  rQ  r=  r=  rQ  r=  rQ  rQ  rQ  rQ  rQ  rQ  r=  )%r   r   r   r   r   r   rO  r   r   r   rO  rO  rO  r   rO  r   rO  r   r   r=  rO  r   r   r   r   rO  r   r   rO  r   rO  rO  rO  rO  rO  rO  r   r   r  )rW   r   r   finfor   r'  rF  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   rT  r   r  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   r?  )r   r   r=  )r   r   r   )r=  r   r   g      @)rW   r   r@  r"   r	   r@  )r   r   r  virC  r2   r2   r3   test_mahalanobis>  s   z*TestSomeDistanceFunctions.test_mahalanobisN)r   r   r   r   r1  r"  rH  r  rN  r  rS  r   r  r  filterwarningsr  r   r   rW  rY  r2   r2   r2   r3   r>    s    
r>  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 rl   )checked_dtypescheck_squareform_matrixr   rF   r2   r2   r3   test_squareform_matrixJ     
z%TestSquareForm.test_squareform_matrixc                 C   r\  rl   )r]  check_squareform_vectorr_  r2   r2   r3   test_squareform_vectorN  ra  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   rj   rj   r   g@ri   )rW   zerosr   r   r   rF   r   r   )r   rF   AZ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 )Nrd  rE   re  r   g @)r   r   )rW   rf  r   r   r   rF   r   r   )r   rF   r  rvr2   r2   r3   rb  c  s   $z&TestSquareForm.check_squareform_vectorc                 C      t ddD ]}| | qd S )Nr   r<  )rv   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   rj   r   r   r   )rW   r   r   r  r   lenr   r   r   rY  rv   )
r   rl  r5  Yrg  ZYrskr   jr2   r2   r3   rj  t  s(   
z,TestSquareForm.check_squareform_multi_matrixN)r   r   r   rW   r   rZ   int32int8r   r]  r`  rc  r^  rb  rm  rj  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  ro  )rv   rW   r   r   r  r   r   )r   rl  r5  rq  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 Nrj   )r   r
  ru   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}  Nro  r  r   r2   r2   r3   test_num_obs_y_4  r  zTestNumObsY.test_num_obs_y_4c                 C   ri  )Nr<     )rv   minit)r   r   r2   r2   r3   test_num_obs_y_5_10  rn  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  rj   r<  i   setrv   addr   r
  ru   bad_yr   rf   rl  r   r2   r2   r3   test_num_obs_y_2_100  s   z TestNumObsY.test_num_obs_y_2_100c                 C   s   t | | d S rl   r  rk  r2   r2   r3   r    r  zTestNumObsY.minitc                 C   s   t j|}t|S rl   )rW   r   r   r   r   rl  r  r2   r2   r3   r    s   zTestNumObsY.bad_yc                 C      t | ||kS rl   )r   make_yrk  r2   r2   r3   r{    r  zTestNumObsY.check_yc                 C   s   t j||d  d S Nrj   r   rW   r   r   rk  r2   r2   r3   r    r7  zTestNumObsY.make_yN)r   r   r   ry  r|  r  r  r  r  r  r  r  r{  r  r2   r2   r2   r3   rx    s    rx  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 )Nrj   r  ro  r   )rv   rW   r   r   r  r   r   rY  r   r   r   )r   rl  r5  rq  rg  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}  rz  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  rl   )r   make_Drk  r2   r2   r3   r    r  zTestNumObsDM.check_Dc                 C   s   t j||S rl   r  rk  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   )r6  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r<  rE   rW   rf  r   r   r
  ru   r  r   r6  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   rf  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   r<  r   )	rW   r   r   r   rv   r   r
  ru   r  r   r  r6  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   r<  r   F)rW   r   r   r   rv   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   rj   rj   rj   r   )rW   r   r   r   r   r
  ru   r  r   r  r6  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  rj   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  )Nre  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 )Nrj   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   )r  r2   r2   r3   is_valid_y_throw0  r  r  c                   @   rw  )TestIsValidYc                 C   r  )Nr   r   rE   rW   rf  r   r   r
  ru   r  r   r  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   rf  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  )Nro  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  )Nr<  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  r+  )g      $g      r=  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 )Nrj   r   r   ro  )r   r
  ru   r#   r0  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
  ru   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rj   r   r   r   ro  r  rj   rj   rj   r   r   rj   r   rj   r   r   )r   	wcanberrar2   r2   r2   r3   r5  |  s   r5  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  r?  )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)rj   rj   rj   r   r   r   r   rI  r  r   Input vector should be 1-DrU  ro  r   iIr  )rW   r   r	   rG  rE  r@  r   r
  ru   Znewaxisr	  r   r   r   r   )rA  rB  r   rsr  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   rj   r  r   r
  ru   whammingrO  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'.rU  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spamr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  z|S4rE   )r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  g?)rW   r   r
   r  )rf   r   Zdesiredr2   r2   r3   test_hamming_string_array  s   

r  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@r  r  g      B@g      N@g     V@g     b@g      8@g      H@r#   rj   )r4   r+  r   )r4   r+  r  r  )rW   r   r   r   r
   )Zarr_inp0Z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  )ro  r<  r  rE   r   r   )Zfloat16Zfloat128)rW   rv  Zint16ru  rv  rG  asarrayr   r   rF   ZfloatingZuint8rB  Zuint32Zuint64Ziinfomaxr   r   rZ   Z	complex64Z
complex128hasattrr   getattr)r   r  rF   dZumaxr  r  Zdtypesr2   r2   r3   test_sqeuclidean_dtypes  s(   

r  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   re   r   r2   r2   r3   rg         z&test_sokalmichener.<locals>.<listcomp>c                 S   r  r2   r  r  r2   r2   r3   rg     r  )r   r   r'   r   )r+  r   r   r  rC  rD  r2   r2   r3   test_sokalmichener  s   

r  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 )Nr=  g?r   r   gX$I?rj   r   r   )FFTTTFFTTTTTTFTFFFTT)TTTFFTTTFTTTTTFFFTTT)g?r,  r   g      4@r  )r	   r   r   r'   )	ZntfZnftZnttZnffexpectedactualZa1Z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   r  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   )r+  rc  re  Zfoorc  r&   re  r"   r+  r#   )rW   r  r   r
  r   r   r   r   )r4   r  r  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   r<  r   rj   )r&   r"   r    not applicabler  r  )rX   rW   r   r   r   r  r  r
  ru   r   r   r   )r4   r5  r   r  r2   r2   r3   test_Xdist_non_negative_weightsM  s(   


r  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   rj   r  rU  r<  rz   r   r   ro  )r   r   rW   r   r   rF   rk   r   r
  ru   r	  r   rO  r2   r2   r3   test__validate_vector_  s,   





"r  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   r=  r*   rj   )rW   r   r   r  r   r   r   )r   r  r2   r2   r3   test_yule_all_samey  s   
r  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   r=  r=  )r=  r   r=  r   r   r=  r?  g)>d?rA  r   ry   rj   gД?T)rw   Zkeepdims)rj   r   r   ro  )r<  r     r_   )	   r        )   rI  r  r  )            )            )g'Y?gTyCЇ?gFw$?g\BZ?)g;0%7/?g)o?gku?)r	   r    rW   r   )rf   r   r2   r2   r3   r    sJ   

r  c                  C   sh   t g d} t g d}t| |}t| |gdd}t|| tt | t |dd}t|| d S )N)rj   r   r   )r   r   r   r   r   )rW   r   r   r   r
   r   rh  )Zarr_1Zarr_2r	  r
  r2   r2   r3   test_gh_17703  s   



r   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&   r  r  rE   F)writer  )r   r  rW   r	  r   Zsetflagsr   r   scipyZspatialZdistance)r4   r   r2   r2   r3   test_immutable_input  s   

"r#  c                   @   rw  )TestJaccardc                 C   r  Nr   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  Nr   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 )Nr  r<  r   r   r  r  r   rW   rf  r
   r   r'  rq  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.  )Nr  r/  r*  r  r  r0  r1  r2   r2   r3   !test_pdist_djaccard_allzeros_nonC  r3  z-TestJaccard.test_pdist_djaccard_allzeros_nonCc                 C   r
  r  wjaccardrW   r   r   r
   r  r2   r2   r3   test_pdist_jaccard_mtica1     z%TestJaccard.test_pdist_jaccard_mtica1c                 C   r
  r  r6  r  r2   r2   r3   test_pdist_jaccard_mtica2  r9  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   rR  rM  r'  r
   r   r   r   )r   r   r  r'  r2   r2   r3   test_non_01_input  s   zTestJaccard.test_non_01_inputN)r   r   r   r'  r(  r+  r,  r-  r2  r4  r5  r8  r:  r<  r2   r2   r2   r3   r$    s    r$  c                   @   r  )TestChebyshevc                 C   r  )Nr   r  pdist-chebyshevr   r  r  r  r2   r2   r3   test_pdist_chebyshev_random	  r  z)TestChebyshev.test_pdist_chebyshev_randomc                 C   r  )NrV  r  r>  r   r   r#  r  r  r2   r2   r3   #test_pdist_chebyshev_random_float32	  r  z1TestChebyshev.test_pdist_chebyshev_random_float32c                 C   r  )Nr   r  r>  test_chebyshevr  r  r  r2   r2   r3    test_pdist_chebyshev_random_nonC	  r  z.TestChebyshev.test_pdist_chebyshev_random_nonCc                 C   r  )Nr3  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  rC  r   r   r#  r  r  r2   r2   r3   !test_pdist_chebyshev_iris_float32'	  r  z/TestChebyshev.test_pdist_chebyshev_iris_float32c                 C   r  )Nr3  r  rC  rA  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  r<  ro  )r   rj   r<  r   r   r  r   r   r   r   r   r   r  r   r2   r2   r3   test_weighted5	  s   "zTestChebyshev.test_weightedc                 C   rG  )Nr  rH  r  r   r   r  rI  rJ  r2   r2   r3   test_zero_weight?	  s   "zTestChebyshev.test_zero_weightN)r   r   r   r?  r@  rB  rD  rE  rF  rK  rL  r2   r2   r2   r3   r=  		  s    
r=  rl   )	NNFTFFFFN)r  Zos.pathrQ   	functoolsr   r   r  numpyrW   r   Znumpy.linalgr   Znumpy.testingr   r   r   r   r	   r
   r   r   r   Zscipy.spatial.distancer"  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*   Zscipy._lib._utilr+   r,   Zfixturer4   rO   r   Z_tdistZ_ytdistrX   r^   ra   rx   r   r   r   r   Zassert_allclose_forgivingr   r   r   strr   r8  r&  r  r  r.  r  r  r  r%  Z
wcityblockZ
wchebyshevrK  rL  Zwkulczynski1r7  rE  rG  r  r  r+  Zwsokalmichenerr2  r   r  r>  r[  rx  r  r  r  r  r  r  r  r  r  r5  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r#  r$  r=  r2   r2   r2   r3   <module>   s   "(,\

 

0	


f  9      TC6#I9
!		





	Q