
    IR-eG                     D   d dl Zd dlZd dlmZ d dlmZ d dlmZ  ej	        ddgddgd	d
gg          Z
 ej	        ddgddgdd	gg          Zej                            de
d dfeddfg          d             Z ed          5  ej                            ddd          Z
ej                            ddd          Zddd           n# 1 swxY w Y   ej                            de
eg          d             Z ed          5  ej                            d dd          Z
ej                            dd d          Zddd           n# 1 swxY w Y   ej                            de
d dfedd fg          d             Z ed          5  ej                            ddd          Z
ej                            ddd          Zddd           n# 1 swxY w Y   ej                            de
ddfeddfg          d             Z ed          5  ej                            d dd          Z
ej                            dd d          Zddd           n# 1 swxY w Y   ej                            de
d dfedd fg          d             Z ed          5  ej                            ddd          Z
ej                            ddd          Zddd           n# 1 swxY w Y   ej                            de
ddfeddfg          d             ZdS )    N)assert_allclose)RipleysKEstimator)NumpyRNGContext                  zpoints, x_min, x_max
   c                 .   d}t          j        ddd          }t          |||||          }t          j        g d          }t	          | || |d          d	
           t          j        g d          }t	          | || |d          d	
           dS )a  
    Test against Ripley's K function implemented in R package `spatstat`
        +-+---------+---------+----------+---------+-+
      6 +                                          * +
        |                                            |
        |                                            |
    5.5 +                                            +
        |                                            |
        |                                            |
      5 +                     *                      +
        |                                            |
    4.5 +                                            +
        |                                            |
        |                                            |
      4 + *                                          +
        +-+---------+---------+----------+---------+-+
          1        1.5        2         2.5        3

        +-+---------+---------+----------+---------+-+
      3 + *                                          +
        |                                            |
        |                                            |
    2.5 +                                            +
        |                                            |
        |                                            |
      2 +                     *                      +
        |                                            |
    1.5 +                                            +
        |                                            |
        |                                            |
      1 +                                          * +
        +-+---------+---------+----------+---------+-+
         -3       -2.5       -2        -1.5       -1
    d   r   g      @r	   )areax_miny_minx_maxy_max)r   r   r   禛 P@r   nonedataradiimodegMbP?atol)r   r   r   ~jtT@r    translationN)nplinspacer   arrayr   )pointsr   r   r   rKestANS_NONE	ANS_TRANSs           @lib/python3.11/site-packages/astropy/stats/tests/test_spatial.pytest_ripley_K_implementationr+      s    J D
AsAAe5  D x11122HHddafEEEDQQQQ22233I44V1=AAA         {   )r   r   )lowhighsizeir%   c                     d}t          |          }t          j        ddd          }t          | || |d          d                    d S )	N2   )r   r      r	   r   r   r   )r   r"   r#   r   )r%   r   r'   r&   s       r*   test_ripley_uniform_propertyr4   E   sX    
 D$'''D
Ar1AD$$F!&AAA!DEEEEEr,   )i  r   zpoints, low, highc                     t          d||||          }t          j        ddd          }|                    |          }g d}|D ]"} || ||          }t	          ||d	           #d S )
Nr   r   r   r   r   r   r         ?   ohserr!   ripleyr   皙?r   r   r"   r#   poissonr   )	r%   r.   r/   r'   r&   KposmodesmKest_rs	            r*   test_ripley_large_densityrC   U   s    !3d#TRRRD
AtR  A<<??D...E 1 16333f4000001 1r,   c                     t          d||||          }t          j        ddd          }t          j        |                    |                    }g d}|D ]5}t          j         || ||                    }t          ||dd           6d S )	Nr8   r   r   r   r   r   r   333333?r9   r   r<   r   rtol)r   r"   r#   meanr>   r   )	r%   r.   r/   r'   r&   	Kpos_meanr@   rA   	Kest_means	            r*   test_ripley_modesrL   e   s    "DCsSSSD
AsBAQ((I...E D DGDDfAA>>>??		94dCCCCCD Dr,   )r2   r   c                     t          d||||          }t          j        ddd          }|                    |          } || |d          }t	          ||d	           d S )
Nr   r6   r   r7   r8   	var-widthr   r<   r   r=   )r%   r.   r/   r'   r&   r?   rB   s          r*   #test_ripley_large_density_var_widthrO   u   sm    !3d#TRRRD
AtR  A<<??DTvQ[999FD&t,,,,,,r,   c                     t          d||||          }t          j        ddd          }t          j         || |d                    }t          j         || |d                    }t	          ||dd	           d S )
Nr8   rE   r   rF   r:   r   rN   r<   rG   )r   r"   r#   rI   r   )r%   r.   r/   r'   r&   
Kest_ohserKest_var_widths          r*   test_ripley_var_widthrS      s    "DCsSSSD
AsBA6AAABBJWTTvQ[IIIJJNJTEEEEEEr,   )numpyr"   pytestnumpy.testingr   astropy.stats.spatialr   astropy.utils.miscr   r$   abmarkparametrizer+   randomuniformr4   rC   rL   rO   rS    r,   r*   <module>r`      s@        ) ) ) ) ) ) 3 3 3 3 3 3 . . . . . .BHq!fq!fq!f%&&BHr1gAwQ()) /1a*q"aj1IJJ0 0 KJ0f _S ; ;
	abx88A
	bs::A; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
 Aq6**F F +*F _S 9 9
	aah77A
	bqx88A9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
 ,1ay1b!*.EFF1 1 GF1 _S ; ;
	abx88A
	c::A; ; ; ; ; ; ; ; ; ; ; ; ; ; ;
 ,1bzAsB<.HIID D JID _S 8 8
	aag66A
	bqw77A8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
 ,1ay1b!*.EFF- - GF- _S : :
	abw77A
	c99A: : : : : : : : : : : : : : :
 ,1bzAsB<.HIIF F JIF F FsZ   ;CCC;EEE;GGG;I  I$'I$";K))K-0K-