
    Ti                         d Z ddlZddlZddlmZ ddlmZ ddlm	Z
 d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd ZdS )z
Test cases for Voronoi Diagram creation.

Overall, I'm trying less to test the correctness of the result
and more to cover input cases and behavior, making sure
that we return a sane result without error or raise a useful one.
    N)
MultiPoint)voronoi_diagram)loadsc                      t          dg          } t          j        d          5  t          |           }d d d            n# 1 swxY w Y   t	          |j                  dk    sJ d S )N      ?r   pointsignore)invalidr   )r   nperrstater   lengeomsmpregionss     /var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/shapely/tests/legacy/test_voronoi_diagram.pytest_no_regionsr      s    	J<	(	(	(B	X	&	&	& & &!"%%& & & & & & & & & & & & & & & w}""""""s   AA
Ac                  |    t          ddg          } t          |           }t          |j                  dk    sJ d S )Nr         ?r   r	      )r   r   r   r   r   s     r   test_two_regionsr      sE    	J
3	4	4	4Bb!!Gw}""""""    c                      t          ddg          } t          | d          }t          |j                  dk    sJ t	          d |j        D                       sJ d S )Nr   r   r	   T)edges   c              3   J   K   | ]}|j                             d           V  dS )
LineStringN)	geom_typeendswith.0rs     r   	<genexpr>ztest_edges.<locals>.<genexpr>&   s2      IIaq{##L11IIIIIIr   )r   r   r   r   allr   s     r   
test_edgesr(       so    	J
3	4	4	4Bb---Gw}""""II7=IIIIIIIIIIr   c                      t          ddg          } t          d          }t          | |          }t          |j                  dk    sJ t          d |j        D                       |j        k    sJ d S )Nr   r   r	   +POLYGON ((0 0, 0.5 0, 0.5 0.5, 0 0.5, 0 0))enveloper   c              3   $   K   | ]}|j         V  d S Narear#   s     r   r&   z(test_smaller_envelope.<locals>.<genexpr>0   $      --!qv------r   r   load_wktr   r   r   sumr0   r   polyr   s      r   test_smaller_enveloper7   )   s    	J
3	4	4	4BABBDb4000Gw}""""--w}-----	999999r   c                      t          ddg          } t          d          }t          | |          }t          |j                  dk    sJ t          d |j        D                       |j        k    sJ dS )	zWhen the envelope we specify is larger than the
    area of the input feature, the created regions should
    expand to fill that area.r   r   r	   z#POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))r+   r   c              3   $   K   | ]}|j         V  d S r.   r/   r#   s     r   r&   z'test_larger_envelope.<locals>.<genexpr>=   r1   r   Nr2   r5   s      r   test_larger_enveloper:   3   s     
J
3	4	4	4B9::Db4000Gw}""""--w}-----::::::r   c                  v    t          d          } t          |           }t          |j                  dk    sJ d S )N#POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))   r3   r   r   r   r6   r   s     r   test_from_polygonr@   @   s>    9::Dd##Gw}""""""r   c                  z    t          d          } t          | d          }t          |j                  dk    sJ d S )Nr*   r   	tolerancer   r>   r?   s     r   'test_from_polygon_with_enough_tolerancerD   G   sC    ABBDdc222Gw}""""""r   c                     t          d          } t          j        t                    5 }t	          | d           d d d            n# 1 swxY w Y   dt          |j                  v sJ dt          |j                  v sJ d S )Nr*   g333333?rB   :Could not create Voronoi Diagram with the specified inputs/Try running again with default tolerance value.r3   pytestraises
ValueErrorr   strvaluer6   excs     r   *test_from_polygon_without_enough_tolerancerP   N   s    ABBD	z	"	" -c,,,,- - - - - - - - - - - - - - - H3	L L     =CINNNNNN   AAAc                     t          d          } t          j        t                    5 }t	          | d           d d d            n# 1 swxY w Y   dt          |j                  v sJ dt          |j                  v sJ d S )Nr<   皙?rB   rF   rG   rH   rN   s     r   4test_from_polygon_without_floating_point_coordinatesrT   Y   s    9::D	z	"	" -c,,,,- - - - - - - - - - - - - - - H3	L L     =CINNNNNNrQ   c                     t          d          } t          j        t                    5 }t	          | d           ddd           n# 1 swxY w Y   dt          |j                  v sJ dt          |j                  v sJ dS )zNA Multipoint with the same "shape" as the above Polygon raises the same error.zMULTIPOINT (0 0, 1 0, 1 1, 0 1)rS   rB   NrF   rG   rH   r   rO   s     r   7test_from_multipoint_without_floating_point_coordinatesrW   d   s    	3	4	4B	z	"	" +cc****+ + + + + + + + + + + + + + + H3	L L     =CINNNNNNrQ   c                     t          d          } t          j        t                    5 }t	          | d           ddd           n# 1 swxY w Y   dt          |j                  v sJ dt          |j                  v sJ dS )z5This multipoint will not work with a tolerance value.MULTIPOINT (0 0, 1 0, 1 2, 0 1)rS   rB   NrF   rG   rH   rV   s     r   Etest_from_multipoint_with_tolerace_without_floating_point_coordinatesrZ   q   s    	3	4	4B	z	"	" +cc****+ + + + + + + + + + + + + + + H3	L L     =CINNNNNNrQ   c                  v    t          d          } t          |           }t          |j                  dk    sJ dS )zBut it's fine without it.rY   r=   Nr>   r   s     r   Htest_from_multipoint_without_tolerace_without_floating_point_coordinatesr\   }   s>    	3	4	4Bb!!Gw}""""""r   )__doc__numpyr   rI   shapely.geometryr   shapely.opsr   shapely.wktr   r3   r   r   r(   r7   r:   r@   rD   rP   rT   rW   rZ   r\    r   r   <module>rc      s)         ' ' ' ' ' ' ' ' ' ' ' ' ) ) ) ) ) )# # ## # #J J J: : :
; 
; 
;# # ## # #O O OO O O
O 
O 
O	O 	O 	O# # # # #r   