
    P/Ph                        d dl Zd dlmZmZmZ d dlmc m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 dlmZmZ  G d d          Zd Zd Zd	 Zd
 Zd Zd Ze
j                             dg g fdgdgfddgddgfg dg dfg dg dfg dg dfg          d             Z!d Z" edg          d             Z#d Z$d Z%d Z&d Z'd  Z(d! Z)d" Z*d# Z+d$ Z,d% Z-d& Z. ed'gd(d)*          d+             Z/ ed,gd(d-*          d.             Z0d/ Z1d0 Z2e
j                             d1ej3        ej4        gd2d3g4          d5             Z5d6 Z6d7 Z7d8 Z8d9 Z9d: Z:d; Z;dEd=Z<d> Z=d? Z>d@ Z? e            dA             Z@dB ZAdC ZBdD ZCdS )F    N)assert_array_equalassert_array_almost_equalassert_array_less)Path)image_comparisoncheck_figures_equalc                   L   e Zd Zg dZg dZg dg dgZddgZej        	                    deegi eeddgfeeegi eeedgfeeg e
e	          eeedgfeeg e
e
          eedegfeeeg e
e
          eeeegfeeg e
ee          eeeegfg          d             ZdS )TestTriangulationParamsr      r   r   r   r   r   r   r      r   r      FTzargs, kwargs, expectedN	trianglesmaskr   r   c                     ddg}ddd}t           j                            ||z   i ||          \  }}}}	}
}|\  }}}}||u sJ ||u sJ t          ||           |	|u sJ |
|k    sJ ||k    sJ d S )Nr   r   r   4)ab)mtriTriangulation_extract_triangulation_paramsr   )selfargskwargsexpected
other_argsother_kwargsx_y_
triangles_mask_args_kwargs_xyr   r   s                   c/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/tests/test_triangulation.py!test_extract_triangulation_paramsz9TestTriangulationParams.test_extract_triangulation_params   s     V
S))<<z!#=f#=#=? ? 	2B
E5' !)1iQwwwwQwwww:y111}}}}
"""",&&&&&&    )__name__
__module____qualname__r+   r,   r   r   pytestmarkparametrizedictr.    r/   r-   r
   r
      s7       AAIII&I4=D[5
QaD$'(
Q		BAy$ 78
Q	***Q9d,CD
Q41at"45
Q		DDdOOOaIt-DE
Q	5551i7NO8  ' ' ' ' 'r/   r
   c                      dg} g dg dg dg| g}t           j                            |i           \  }}}}}}|J || gk    sJ d S )NTr   r   r   r   r   r   r   )r   r   r   )r   r    r%   r&   r'   r(   r)   r*   s           r-   *test_extract_triangulation_positional_maskr;   +   sh    6DIIyyy999+t4D88rBB .BJug===TF??????r/   c                     g d} g d}t          j        t          d          5  t          j        | ddg           d d d            n# 1 swxY w Y   t          j        t          d          5  t          j        | |g d           d d d            n# 1 swxY w Y   t          j        t          d	          5  t          j        | |d
           d d d            n# 1 swxY w Y   t          j        t          d          5  t          j        | |g dg           d d d            n# 1 swxY w Y   t          j        t          d          5  t          j        | |g dg           d d d            d S # 1 swxY w Y   d S )Nr   r   zx and y must be equal-lengthmatchr   r   z>triangles must be a \(N, 3\) int array, but found shape \(3,\)r   z3triangles must be a \(N, 3\) int array, not 'other'otherzfound value 99)r   r   c   zfound value -1)r   r   r   r3   raises
ValueErrorr   r   r+   r,   s     r-   test_triangulation_initrE   7   s   AA	z)G	H	H	H & &1q!f%%%& & & & & & & & & & & & & & &	
 
 
 , , 	1a+++	, , , , , , , , , , , , , , ,
 
H
J 
J 
J * * 	1a)))* * * * * * * * * * * * * * * 
z)9	:	:	: / /1a***.../ / / / / / / / / / / / / / /	z)9	:	:	: / /1a***.../ / / / / / / / / / / / / / / / / /sY   AAA.BBB9CC #C D((D,/D,E55E9<E9c                     g d} g d}g dg dg}t          j        | ||          }t          |j        g dg dg           |                    ddg           t          |j        ddg           |                    d            |j        J d	}g d
dgdgddfD ]J}t          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   Kd S )Nr   r   r   )r   r   r   )r   r   r   )r   r   r   FTz3mask array must have same length as triangles array)FTFr=   )	r   r   r   	neighborsset_maskr   r3   rB   rC   )r+   r,   r   triangmsgr   s         r-   test_triangulation_set_maskrK   K   s\   AAIII&I1i00F v'+++{{{)CDDD OOUDM"""v{UDM222 OOD;
@C%%%wtD " "]:S111 	" 	"OOD!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"" "s   8CC	!C	c                     d} d}t          j        t          j        dd|           t          j        dd|                    \  }}|                                }|                                }| |z  }d| dz
  z  |dz
  z  }d| z  |z  d| z  z
  d|z  z
  dz   }t	          j        ||          }t          |j        |           t          |j        |           t          |j
                  |k    sJ t          j        |j
                  dk    sJ t          j        |j
                  |dz
  k    sJ t          |j                  |k    sJ t          j        |j                  dk    sJ t          j        |j                  |dz
  k    sJ |j        }d |_        t!          |j        |           t!          t          j        |j
                  t          j        |                     d S )	N                    ?r   r   r   r   )npmeshgridlinspaceravelr   r   r   r+   r,   lenr   minmaxedgesrG   
_neighborsr   uniquearange)	nxnyr+   r,   npoints
ntrianglesnedgesrI   rG   s	            r-   test_delaunayra   b   s   	
B	
B;r{3R00"+c32K2KLLDAq			A			AeGbdr!t$JrT"Wqt^ad"Q&F 1%%F fh***fh*** v  J....6&"##q((((6&"##wqy0000 v|&&&&6&,1$$$$6&,719,,,,
  IFv'333 ry!122BIg4F4FGGGGGr/   c                     d} d}d}t           j                            d           t           j                            |           }t           j                            |           }||         ||<   ||         ||<   t          j        ||          }t          t          j        |j                  t          j        t          j	        |           |                     d S )N
      r      )
rQ   randomseedr   r   r   rZ   r   deleter[   )r^   	duplicateduplicate_ofr+   r,   rI   s         r-   test_delaunay_duplicate_pointsrk      s    GILINN2
	!!A
	!!A\?AiL\?AiL 1%%F ry!122y7!3!3Y??A A A A Ar/   c                  h   t          j        ddd          } t          j        ddd          }t          j        t                    5  t          j        | |           d d d            n# 1 swxY w Y   t          j        | d          } t          j        |d          }t          j        | |           d S )NrO         $@          @g       @)rQ   rS   r3   rB   RuntimeErrorr   r   appendrD   s     r-   test_delaunay_points_in_linerr      s     	Cr""A
Cr""A	|	$	$ ! !1a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 		!SA
	!SAq!s   A((A,/A,zx, yr   rM   r      )r   r   r   )rM   rs   rM   r   r   r   )rM   rs   rs   )r   r   r   r   r   r   )rM   rM   rM   rs   rM   rs   c                     t          j        t                    5  t          j        | |           d d d            d S # 1 swxY w Y   d S NrA   rD   s     r-   !test_delaunay_insufficient_pointsrw      s     
z	"	" ! !1a   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   =AAc            
         t          j        ddgddgddgddgddgd	d
gddgg          } t          j        ddgddgddgddgddgddgddgg          }d fd}t          j        | d d df         | d d df                   }|D ]} |||          dk    sJ t          j        | dd df         | dd df                   }d S )NgLXz?g     gCM??g~9B.?g     g/7R?g9?g     ڿgHC?g     ڿgt?g     ڿg(\?gq=
ףpݿg?gzGڿffffff?gQ޿g)\(ܿ      ?皙?c                 |    t          j        | |f          j        }t          |                              |          S rv   )rQ   vstackTr   contains_point)xtriytrixy
tri_pointss       r-   tri_contains_pointz0test_delaunay_robust.<locals>.tri_contains_point   s4    Yd|,,.
J..r222r/   c                 L     t           fd j        D                       S )Nc              3   ^   K   | ]'} j         |         j        |                   V  (d S rv   rD   ).0trir   rI   r   s     r-   	<genexpr>zCtest_delaunay_robust.<locals>.tris_contain_point.<locals>.<genexpr>   sR       0 0 &%fhsmVXc]BGG 0 0 0 0 0 0r/   )sumr   )rI   r   r   s   ``r-   tris_contain_pointz0test_delaunay_robust.<locals>.tris_contain_point   sJ     0 0 0 0 0 0$.0 0 0 0 0 	0r/   r   r   )rQ   arrayasarrayr   r   )r   test_pointsr   rI   
test_pointr   s        @r-   test_delaunay_robustr      s[    	01	01	01	01	01	01	124 5 5J *	u	u	u	e	e	u	e  K3 3 30 0 0 0 0 
111a4 0*QQQT2BCCF! ; ;
!!&*55::::: 
122q5 1:abb!e3DEEFFFr/   ztripcolor1.pngc                     t          j        g d          } t          j        g d          }t          j        g dg dg dg dg dg dg d	g d
g dg dg
          }t          j        | ||          }| d|z  z   }| |j                                     d          }||j                                     d          }d|z  |z   }t          j        d           t          j        ||d           t          j	        d           t          j        d           t          j        ||d           t          j	        d           d S )N)
r         ?r   r   r   r   r   r   r   rz   )
r   r   r   r   r   r   r   r   r   rz   r   r   r   )r   rN   r   r   r   rN   )r   rM   rN   )r   rN   rs   )rN   rd   rs   )rN   rM   	   )rd   rN   r   )   rd   r   )rM   r   r   r   r   axisy   k)
edgecolorszpoint colorsz   )
facecolorsr   r   )
rQ   r   r   r   r   meanpltsubplot	tripcolortitle)r+   r,   r   rI   CpointsxmidymidCfacess           r-   test_tripcolorr      sd   

>>>??A

>>>??A
		999		999		999		999iii	4 5 5I 1i00F#a%iGV###++DV###++DX_FKM&'c2222InKM&V<<<<Ilr/   c                  @   g d} g d}t          j                    \  }}t          j        t          d          5  |                    | |           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    | |g d           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    | |g d	           d d d            n# 1 swxY w Y   t          j        t          d
          5  |                    | |ddgd           d d d            n# 1 swxY w Y   t          j        t          d
          5  |                    | |ddgd           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    | |g d           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    | |ddgd           d d d            n# 1 swxY w Y   |                    | |g d           |                    | |g dd           |                    | |ddg           |                    | |ddg	           d S )Nr   r   z!tripcolor\(\) missing 1 required r=   z!The length of c must match eitherr   r   r   z,length of facecolors must match .* triangles)r   r   r   rN   r   z-'gouraud' .* at the points.* not at the facesr   r   gouraud)r   shading)r   z+positional.*'c'.*keyword-only.*'facecolors')CzUnexpected positional parameterunused_positional)r   subplotsr3   rB   	TypeErrorr   rC   )r+   r,   figaxs       r-   test_tripcolor_colorr     s   AAlnnGC	y(L	M	M	M  
Q              	z)L	M	M	M & &
Q999%%%& & & & & & & & & & & & & & &	zK
M 
M 
M 4 4
Qlll3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
zL
N 
N 
N A A
Qq!fi@@@A A A A A A A A A A A A A A A 
zL
N 
N 
N 6 6
QAq695556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 
yJ
L 
L 
L + +
Q\\\***+ + + + + + + + + + + + + + + 
y(I	J	J	J 8 8
QAq6#67778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 LLA|||$$$LLA|||YL777LLA1vLLA1a&L)))))s}   AA!$A!B))B-0B-C66C:=C:EEE*FFF8GG#&G#H,,H03H0c                     t           j                            d           t           j                            d          t           j                            d          t           j                            d          }}} t	          j                                                    }d}|                    | |||          j        }|j	        |j
        f|k    sJ d S )Ni!N,rc   )      ?rz   )clim)rQ   rf   rg   randr   figureadd_subplotr   normvminvmax)r   r   cr   r   r   s         r-   test_tripcolor_climr   %  s    INN8innR  ").."4"4binnR6H6H!qA		!	!	#	#BD<<1ad<++0DIty!T))))))r/   c                  |   g d} g d}ddg}t          j                    \  }}t          j        t          d          5  |                    | |||           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    | |d|           d d d            d S # 1 swxY w Y   d S )	Nr   r   皙?r   z"Positional parameter c .*no effectr=   r   zinterpreted as c)r   r   r3   warnsUserWarningr   )r+   r,   r   r   r   s        r-   test_tripcolor_warningsr   /  sF   AA	c
AlnnGC	k)M	N	N	N , ,
Q1+++, , , , , , , , , , , , , , ,	k)M	N	N	N = =
Q-!<<<= = = = = = = = = = = = = = = = = =s#   A$$A(+A(
B11B58B5c                  $   t          j        g dg dgt           j                  } t          j        g d          }|                                 }t	          j        |d d df         |d d df         |           j         t          ||            d S )Nr   r   r   )r   r   r   dtype))r   r   )r   g?)r   r   )r   r   r   r   )rQ   r   int32copyr   r   rX   r   )r   pointsold_triangless      r-   test_no_modifyr   ;  s    )))YYY/rx@@@IX88899FNN$$Mvaaad|VAAAqD\9==CC}i00000r/   c                  b   t          j        t          j        d          t          j        d                    \  } }|                                 } |                                }g dg dg dg dg dg dg dg d	g d
g dg dg dg dg dg dg dg dg dg}t          j        t          |                    }d|dd<   t          j        | |||          }|                                }g d}g d}t          j        ||          \  }}|                                }|                                } |||          }t          |g d            ||dz
  |dz
            }t          |g d           g d}g d} |||          }t          |g d           ddg}ddg} |||          }t          |d d!g           d}	g d"} d#d d d d |	dg}g d$g d%g d&g dg d'g d(g d)g d*g}t          j        | ||          }|                                }g d+}d,d-g}t          j        ||          \  }} |||          }t          |g d.g d/g           d}	d#|	 d d d d dg} g d0}g d1g d2g d3g d4g d5g d6g d7g d*g}t          j        | ||          }|                                }d,d-g}g d+}t          j        ||          \  }} |||          }t          |d#d#gd d8gd d8gd d9gdd9gdd:gd#d#gg           g d;} g d<}g d1g d=g}t          j        | ||          }|                                }g d>}g d?} |||          }t          |g d@           |
                    dd g           ||                                k    sJ  |||          }t          |g dA           d S )BNrN   r   r   rN   r   rM   rN   r   r   rM   r   rs   rM   r   r   rs   r   rd   rs   rN   rM   r   rM   r   r   rM   rs   r   rs   rc   r   rs   rd   rc   rd   rn   rc   r   r      r      r   r   rc   r   rc      r   rc   rn   r   rn      r   r   r   rc   )r         ?      @      
@)r   r   rN   r   rs   r   rc   r   r   r      r   r   r   r   r   r   )r   r   r   r   r   r   r   rM   r   rd   r   rn   r   r   r      )r         ?      @r   r   r   r   r   rO   rP   ro         @)rO   rO   rO   r   r   r   rP   ro   r   r   r   r   )r   r   rN   r   r   r   r   r   rs   rd   rc   rn   rO   r   r   r   r   r   r   r   r   r   r   r   r9   r   r   r   r   rN   r   r   r   rM   r   rN   rM   r   rM   rs   rN   rs   rM   )皙r   ?gffffff?gffffff?g333333@g333333@r   皙?)r   r   r   r   r   r   r   )r   rs   rs   rs   rd   rd   r   )r   r   r   r   r   r   r   r   )r   r   rM   r   )r   r   rN   )r   rN   rM   )r   rs   r   )r   rs   rN   rM   rs   rd   r   r   r   r   r   r   r   r   r   r   r   )gɿ皙?r{   g333333?)r   r   r   r   )r   r   r   r   )r   r   r   r   )rQ   rR   r[   rT   zerosrU   r   r   get_trifinderr   rH   )
r+   r,   r   r   rI   	trifinderxsystrisdeltas
             r-   test_trifinderr  E  s   ;ry||RYq\\22DAq			A			AIIIyyy)))YYYIIIyyy)))ZZZ[[[***kkk;;;|||\\\;I 8C	NN##DD2J1i66F$$&&I	!	!	!B	!	!	!B[R  FB	B	B9RDt > > > ? ? ?9RVRV$$Dt = = = > > > 
F	E	EB	E	E	EB9RDtGGGHHH sB
sB9RDtaW%%% E'''A	a!aE1%AIIIyyy)))YYYIIIyyy2I1i00F$$&&I	-	-	-B
B[R  FB9RDt5555557 8 8 8 E	eVQQ1%A'''AIIIyyy)))YYYIIIyyy2I1i00F$$&&I
B	-	-	-B[R  FB9RDtr2hAAAAA!2h( ) ) )
 	AAIII&I1i00F$$&&I			B			B9RDt^^^,,,
OOQF,,......9RDt___-----r/   c                     t          j        t          j        d          t          j        d                    \  } }|                                 } |                                }d| z  d|z  z
  }g dg dg dg dg dg d	g d
g dg dg dg dg dg dg dg dg dg dg dg}t          j        t          |                    }d|dd<   t          j        | |||          }t          j        ||          }t          j	        ||          }t          j	        ||d          }t          j
        ddd          }	g d}
t          j        |	|
          \  }	}
|||fD ]'} ||	|
          }t          |d|	z  d|
z  z
             (g d}	|	}
t          j        |	|
          \  }	}
|||fD ]+} ||	|
          }t          |j        d gdz  gdz             ,t          j
        dd!d          }	g d"}
t          j        |	|
          \  }	}
|||fD ]\} ||	|
          }t          j        |d|	z  d|
z  z
             |	dk    |	d#k    z  |
dk    z  |
d#k    z  }t          |j        |           ]d$\  fd%}fd&}t          j        g d'          } t          j        g d(          }t          j        g d)g d*g d+g d,g d-g d.g d/g d0g          }t          j        | ||          } || |          } || |          }t          j
        d1d2d3          }	t          j
        d1d2d3          }
t          j        |	|
          \  }	}
t          j	        ||d4|5          } ||	|
          }t          | ||	|
                     |                    | |          \  }} || |          \  }}t          ||           t          ||           d6}t          j        t          j
        d1d2|dz             t          j
        d1d2|dz                       \  } }|                                 } |                                } || |          }t          j        | |t#          |dz             7          }t          j        t          j
        d8d9d3          t          j
        d8d9d3                    \  }	}
|	                                }	|
                                }
t          j        ||          }t          j	        ||          }t          j	        ||d          } ||	|
          }t          j         ||	|
          |z
            }||fD ]}t          j         ||	|
          |z
            }t          j        |          dt          j        |          z  k    sJ t          j        ||          d:t          j        ||          z  k    sJ d S );NrN   Gz?)\(@r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rc   geomkindr         @rs   )r   rz   r   r  )g      пr         ?r   Tr	  )r   rz   r   r	  r   )r  g)\(333333?c                 D    | dz
  dz  z  |dz
  dz  z  z   | z  |z  z   S )Nr   r   r7   r+   r,   r   r   r   s     r-   quadztest_triinterp.<locals>.quad  s3    !C%!|a3
l*QqSU22r/   c                 H    dz  | dz
  z  |z  z   dz  |dz
  z  | z  z   fS )Nr   r   r7   r  s     r-   gradient_quadz%test_triinterp.<locals>.gradient_quad  s8    !QsUac!1Q3#;1#455r/   )r   &jjZ? rh?rO   rP   rP   rO   )333333?HPs?X9v?rO   rO   rP   rP   r   r   r   rN   rN   r   r   rN   r   rM   r   rM   r   rs   rM   r   rs   r   r   rs   r   r   rO   rP   rM   userr  dzrn   r   r   r   d   )rQ   rR   r[   rT   r   rU   r   r   LinearTriInterpolatorCubicTriInterpolatorrS   r   r   r   matestr   gradientmeshgrid_trianglesabsrW   dot)r+   r,   zr   r   rI   linear_interpcubic_min_E
cubic_geomr   r   interpzsr  r  r  
cubic_user	interp_zsinterp_dzsdxinterp_dzsdydzsdxdzsdyndiff_lin
diff_cubicr   r   r   s                            @@@r-   test_triinterpr6    s   ;ry||RYq\\22DAq			A			AQaAIIIyyy)))YYYIIIyyy)))ZZZ[[[***kkk;;;|||\\\;I 8C	NN##DD2J1i66F.vq99M+FA66K*616BBBJ	T4	#	#B	!	!	!B[R  FB +z: ; ;VB^^!"tBwb'8:::: 
#	"	"B	B[R  FB +z: 2 2]2r""27dVAXJqL1111 
T4	#	#B	!	!	!B[R  FB +z: * *VB^^(d2gR.?AAAaB!G$a0B!G<27D))))
 #IQ13 3 3 3 3 3 36 6 6 6 6 6 6 	66677A
77788A)))YYY			999#))YYY			999F G GI1i00FQ

A	q!		B	RQ		B	RQ		B[R  FB*616bIIIJ
2r""Iib"666#-#6#6q!#<#< \<"]1a((NUElE222lE222 	A;r{2r1Q3//RQqS1I1IJJDAq			A			AQ

A10B1Q30G0GHHHF[S#q112;sC3K3KLLFB	B	B.vq99M+FA66K*616BBBJ	b"BvmmB++b011H
+ 6 6VFF2rNNR/00
vh2z(:(:#:::::x**bfZ4445 5 5 5 56 6r/   c                  B   dd} d\  }}d\  }}d\  }}t          j        |||ddddg          }t          j        |||ddddg          }t          j        g dg dg d	g d
g dg dg dg dg          }	t          j        |||	          }
t	          d          D ]}t          j        dt           j                  }t          j        dt           j                  }t          j        dt           j                  }t          j        ddgt           j                  }|dz  }d|||dz  f<   |dk    rd||<   n|dk    r	d||dz  <   n|dk    rd||dz  <   t          j        |
|d||f          } | |||f|d d df                     | |||f|d d df                     | |||f|d d df                     | |||z   dz  ||z   dz  f            | |||z   dz  ||z   dz  f            | |||z   dz  ||z   dz  f            | |||z   |z   dz  ||z   |z   dz  f            | |d|z  |z   |z   dz  d|z  |z   |z   dz  f            | ||d|z  z   |z   dz  |d|z  z   |z   dz  f            | |||z   d|z  z   dz  ||z   d|z  z   dz  f           d S )Nc           	         d}d}d}|\  }}||t          j        t          j        ddt           j        z  |                    z  z   }||t          j        t          j        ddt           j        z  |                    z  z   }	 | |g|g          d         }
|                     |g|g          \  }}|Nt          |
|d                    t          |d         |d                    t          |d         |d                     | ||	          |
z
  }|                     ||	          \  }}||z
  }||z
  }t          |||z             t          |||z             t          |||z             dS )	aJ  
        Checks the continuity of interpolator (and its derivatives) near
        location loc. Can check the value at loc itself if *values* is
        provided.

        *interpolator* TriInterpolator
        *loc* location to test (x0, y0)
        *values* (optional) array [z0, dzx0, dzy0] to check the value at *loc*
           绽|=g      Y@rO   r   r   Nr   )rQ   cosrS   pisinr#  r   r   )interpolatorlocvaluesn_starepsilonr   loc_xloc_ystar_xstar_yr'  dzxdzydiff_ztab_dzxtab_dzydiff_dzxdiff_dzys                     r-   check_continuityz;test_triinterpcubic_C1_continuity.<locals>.check_continuity  s{    B"%(H(H!I!IIIB"%(H(H!I!IIIL%5'**1-!**E7UG<<
c%a333%c!ffQi888%c!ffQi888ff--1)2266BB'S=S=&'!),,,(GAI...(GAI.....r/   )r   r  )r  r  )r  r  rO   rP   r   r  r  r  r  r  r  r  r   rd   r   r   r   r   r   r  r  r   r         @g      @rv   )rQ   r   r   r   ranger   float64r!  )rN  r   aybxbycxcyr+   r,   r   rI   idofr'  rG  rH  r@  caser+  s                     r-   !test_triinterpcubic_C1_continuityrY    s   / / / /> HR!HRHR
"b"b"b"-..A
"b"b"b"-..A)))YYY			999#))YYY			999F G GI1i00Fa G GHQbj)))hq
+++hq
+++1a&
333Qw!$tTAX~199AdGGQYYCqMMQYYCqM*616/2Cj: : : 	"b6!!!Q$<888"b6!!!Q$<888"b6!!!Q$<8882b5#+2s{!;<<<2b5#+2s{!;<<<2b5#+2s{!;<<<2b58R-"R%(B!?@@@2b58B;"2RU2Xb["4D!EFFF2be8B;"2R2Xb["4D!EFFF2b5B;"2RU2b5["4D!EFFFF9G Gr/   c            	         d } d\  }}t          j        j         | ||           }|                                 |                                }t          ||z            D ]}t          j        ||z  t          j                  }d||<   t           j        	                    ||t          j        ||z            d          \  }}t          t          j        ||          |           d\  }	}
 | ||          \  }}}}|d||	k    z  z   d||
k    z  z   }|d||	k    z  z   d||
k    z  z   }t          j        ||	|	dz
  |
|
dz
  gg          }t          j        ||	dz
  |	|
dz
  |
gg          }t          j        |g d	g          }t           j                            |||||z  d
z   ||z  d
z   f          }|                                 |                                }t          ||z  d
z             D ]}t          j        ||z  d
z   t          j                  }d||<   t           j        	                    ||t          j        ||z  d
z             d          \  }}t          t          j        ||          |           t          j        dt          j                  }t          j        g dt          j                  }t          j        g dt          j                  }d}t           j                            ||||          }|                                 |                                }t          |t          j        g dg dg dgt          j                             d S )Nc                    || z  }t          j        t          j        |t           j                  t          j        |dz
  t           j                  t          j        d|t           j                  t          j        || z
  t           j                  t          j        | |t           j                  g          }t          j        t          j        |t           j                  t          j        d|t           j                  t          j        |dz
  t           j                  t          j        | |t           j                  t          j        || z
  t           j                  g          }t          j        dt          j        |t           j                  z  t          j        |dz
  t           j                   t          j        |dz
  t           j                   t          j        || z
  t           j                   t          j        || z
  t           j                   g          }d||d|z  dz
           |dz
  d|<   d|d|z  dz
  d|z  dz
           |dz
  d|<   |||| |z  | |z  ffS )z
        Return the sparse, (n*m, n*m) matrix in coo format resulting from the
        discretisation of the 2-dimensional Poisson equation according to a
        finite difference numerical scheme on a uniform (n, m) grid.
        r   r   rN   rO   r   Nr   )rQ   concatenater[   r   onesrQ  )r3  mlrowscolsvalss         r-   poisson_sparse_matrixz<test_triinterpcubic_cg_solver.<locals>.poisson_sparse_matrixe  s)    aC~Iarx(((Iac***BIa"(,K,K,KIac***BIa"(,K,K,KM N N ~Iarx(((Ia"(+++RYqs"(-K-K-KIa"(+++RYqs"(-K-K-KM N N ~bgarz****WQqS
++++bgac.L.L.L-LWQqS
++++bgac.L.L.L-LN O O
 !#Qqs1uWacf1f$&QqSU1Q3q5[!A#&q&!T4!A#qs++r/   )r   rN   r   rP   r:  )Ar   x0tol)r   1   r   )rP   rP   rP   rP   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   r   r   r   )r   r   )rP   ro   rO   )ro   rP         @)rO   rh  rP   )r   _triinterpolate_Sparse_Matrix_coocompress_cscto_denserP  rQ   r   rQ  _cgr   r&  r\  r]  r   r   )rc  r3  r^  mat	mat_denseitestr   r+   _i_zeroj_zerorb  r`  ra  dims                  r-   test_triinterpcubic_cg_solverru  a  s   , , ,2 FQ


13H3HA3N3N
OCIqs ; ;HQqS
+++%#''#rx!}},2 ( 4 41!"&A"6"6::::  VV//155D$a!TV^$$q$&.'99D!TV^$$q$&.'99D>4&&(FF1H!EFGGD>4&(FF1Hf!EFGGD>4!1!1!1233D


1
1$d34Q37AaC!G2DF FCIqsQw ; ;HQqS1WBJ///%#''#rwq1uqy7I7I,2 ( 4 41!"&A"6"6:::: 72RZ(((D8GGG($ $ $D8GGG($ $ $D
C


1
1$dC
H
HCIilllLLL329;*E *E *E F F F F Fr/   c                  .   d\  } }t          j        | d| z  ddg          }t          j        || ddg          }t          j        dt           j                  }g dg dg}t          j        dd	g          }t          j        dd	t           j        z  d
          D ]x}t          j        |          |z  t          j        |          |z  z   }t          j        |           |z  t          j        |          |z  z   }	t          j	        ||	|          }
t          j
        |
|d          }t          j                            |          }|                                }t          j        |d          dz
  |dd d f<   t          d          D ]1}t          j        |d          d	|d d |f         z  z
  ||dz   d d f<   2t!          t          j        t          j        |          d          t          j        ddgt           j                             zd S )N)rO   gˡE?r   rO   rP   rN   r   r   r   r   r   r  r  r   r   r   r   )rQ   r   r   rQ  rS   r<  r;  r=  r   r   r!  ri  _DOF_estimator_geomcompute_geom_weightsr   rP  r   rV   r%  )r   rR  r+   r,   r'  r   sum_wthetax_roty_rotrI   r*  dof_estimatorweightsitris                  r-    test_triinterpcubic_geom_weightsr    s	   
 HR
"c"fb"%&&A
"rc2r"##A
"*%%%AIII&IHaVER25"-- H Hua"&--/1q 26%==?2#E5)<<.vqvFFF
,@@LL4466fWa((1,ad!HH 	G 	GD!vgq11Agaaag6F4FFE$q&!!!)!"&Q"?"?"?"$(B82:"F"F"F	H 	H 	H 	HH Hr/   c                     d} t          j        g d          }t          j        ddddd| dg          }ddgddgddgddgddgddgg}|D ]}|d         |z  |d         |z  z   }|d          |z  |d         |z  z   }||}}d|z  d	|z  z
  }	g d
g dg dg dg dg dg dg dg}
t          j        |||
          }t          j        t          j        |j                  t          j        |j                  d          }t          j        t          j        |j                  t          j        |j                  d          }t          j	        ||          \  }}|
                                }|
                                } |                                ||          dk    }t           j                            d|z  d	|z  z
  |          }t          j        ||	          }t          j        ||	          }t          j        ||	d          }|||fD ]} |||          }t          ||           d}|j        |df         }|j        |df         }t          j        |j        |         |j        |         d          }t          j        |j        |         |j        |         d          }d|z  d	|z  z
  }|||fD ]M}|                    |||t          j        dt           j                  z            \  }t          ||           Nd S )NrO   r   r   r   r   r   r  r  r9   r   r   r   r   r   r   r      r   r  r  rN   rc   r   )	tri_index)rQ   r   r   r   rS   rV   r+   rW   r,   rR   rT   r   mar   r!  r   r   _interpolate_multikeysr]  r   )r   re  y0transformationstransformationr{  r|  r+   r,   r'  r   rI   r   r   mask_out	zs_targetr(  r)  r*  r+  r,  r  pt1pt2s                           r-   test_triinterp_colinearr    sI    E	111	2	2B	2A1eQ/	0	0B 1v1v1v1vBx"aIO) #5 #5q!"$~a'8';;""2%q(9"(<<AFT!VOYY			999iiiYY			9996	#Aq)44[))26&(+;+;R@@[))26&(+;+;R@@R$$BXXZZXXZZ*F((**2r22b8EKKR$r' 1KAA	261==/::.vqvFFF
$k:> 	5 	5FBB%i4444 tQw'tQw'[#r::[#r::Gd2g%	$k:> 	5 	5F//B$rwr'B'B'B"B 0 D DCB%i4444	5A#5 #5r/   c                     d} d}d}d }t          j        |d|          }t          j        d| z   dt           j        z  | z   | d	          }t          j        |d
t           j        f         |d          }|d d dd dfxx         t           j        | z  z  cc<   |t          j        |          z                                  }|t          j        |          z                                  }t          j	        ||          } |||          }	t          j        ddd          }
t          j        ddd          }t          j
        |
|          \  }
}|
                                }
|                                }i }t          d          D ]}dt           j        z  | z  |z  }t          j        |          |z  t          j        |          |z  z   }t          j        |           |z  t          j        |          |z  z   }t          j        |          |
z  t          j        |          |z  z   }t          j        |           |
z  t          j        |          |z  z   }t          j	        |||j                  }t          j        ||	          }t          j        ||	          }t          j        ||	d          }|||d}dD ]G}||         }|dk    r ||
|          ||<     |||          }t!          j        |||                    Hd}dD ]}|dk    r||z  }|}||
z  }|}n|}||z  }|
}||z  }t          j	        |||j                  }t          j        ||	          }t          j        ||	          }t          j        ||	d          }|||d}dD ]/} ||         ||          }t!          j        |||                    0d S )Nr  rc   333333?c                 l   t          j        d| z
  d|z
            }t          j        d| z
  d|z
            }t          j        |  dz
  | dz
            }t          j        |  dz
  | dz
            }dt          j        |dz  dz            dz
  z  dz  t          j        d|z            z  t          j        |dz  dz            dz
  dz  t          j        d|z            z  z   d	| dz  |dz  z   z  z    }t          j        |          |z
  t          j        |          t          j        |          z
  z  S 
Nr   r   r   rc   r   g      >@      @g      &@ry   rQ   hypotarctan2expr;  rW   rV   r+   r,   r1theta1r2theta2r'  s          r-   r'  z)test_triinterp_transformations.<locals>.z  *   XcAgsQw''C!GS1W--Xqb3hS))QBHqb3h//B
##A%&s*RVBvI->->>vr"uqj!!!#S(26#f*+=+==>1a4!Q$;  ! q		!bfQiiq		122r/   ffffff?r   r   Fendpoint.r   r         rP   re   r  r  )linmin_Er  gZ$.ArD   r+   )rQ   rS   r<  repeatnewaxisr;  flattenr=  r   r   rR   rT   rP  r   r   r!  r"  r   )n_anglesn_radii
min_radiusr'  radiianglesre  r  triang0z0xs0ys0	interp_z0i_anglerz  r+   r,   r   r   rI   r(  r)  r*  
dic_interp
interp_keyr+  interpzscale_factorscaled_axiss                                r-   test_triinterp_transformationsr    s*    HGJ3 3 3 K
D'22E[Xqw'9!E3 3 3FYvc2:o.a@@@F
111add7OOOruX~%OOO
v
	'	'	)	)B
v
	'	'	)	)B R((G	
2rB +c2r
"
"C
+c2r
"
"C{3$$HC
))++C
))++CI88 H H"%("W,F5MM"rve}}R//VE]]N2ub 00VE]]3s!22fUmm^C"&--"33#Aq'*;<<262>>/;;.vrGGG
**(* *
 3 	H 	HJ
+F!||(.sC(8(8	*%% &R..01::1FH H H H	H L! M M#r!AA#BBBAr!AB#B#Aq'*;<<262>>/;;.vrGGG
**(* *
 3 	M 	MJ,j,R44G,Wi
6KLLLL	M)M Mr/   ztri_smooth_contouring.pngTg;On?)remove_textrf  c                     d} d}d}d }t          j        |d|          }t          j        d| z   dt           j        z  | z   | d	          }t          j        |d
t           j        f         |d          }|d d dd dfxx         t           j        | z  z  cc<   |t          j        |          z                                  }|t          j        |          z                                  }t          j	        ||          } |||          }	|
                    t          j        ||j                                     d          ||j                                     d                    |k                t          j        |          }
|
                    |	d          \  }}t          j        ddd          }t#          j        |dd           t#          j        |||d           d S )Nr  rc   r  c                 l   t          j        d| z
  d|z
            }t          j        d| z
  d|z
            }t          j        |  dz
  | dz
            }t          j        |  dz
  | dz
            }dt          j        |dz  dz            dz
  z  dz  t          j        d|z            z  t          j        |dz  dz            dz
  dz  t          j        d|z            z  z   d	| dz  |dz  z   z  z    }t          j        |          |z
  t          j        |          t          j        |          z
  z  S r  r  r  s          r-   r'  z%test_tri_smooth_contouring.<locals>.zk  r  r/   r  r   r   Fr  .r   r   rN   subdivrO   rP   g?r   z0.5)lwcolorblack)levelscolors)rQ   rS   r<  r  r  r;  r  r=  r   r   rH   r  r   r   UniformTriRefinerrefine_fieldr[   r   triplot
tricontour)r  r  r  r'  r  r  re  r  r  r  refinertri_refiz_test_refir  s                 r-   test_tri_smooth_contouringr  d  s    HGJ3 3 3 K
D'22E[Xqw'9!E3 3 3FYvc2:o.a@@@F
111add7OOOruX~%OOO
v
	'	'	)	)B
v
	'	'	)	)B R((G	
2rBRXb!2388a8@@ !2388a8@@B B!" # # #
 $W--G#00A0>>HkYr2u%%FKCu----N8[HHHHHHr/   ztri_smooth_gradient.pnggZd;O?c                  \   d } d}d}d}t          j        |d|          }t          j        ddt           j        z  |d	          }t          j        |d
t           j        f         |d          }|d d dd dfxx         t           j        |z  z  cc<   |t          j        |          z                                  }|t          j        |          z                                  } | ||          }t          j	        ||          }	|	
                    t          j        ||	j                                     d          ||	j                                     d                    |k                t          j        |	          }
|
                    |d          \  }}t          j        |	|           }|                    |	j        |	j                  \  }}t          j        ||          }t)          j                     t)          j                                        d           t)          j        |	d           t          j        ddd          }t4          j        d         }t)          j        ||||g d           t)          j        |	j        |	j        ||z  ||z  ddddddd           d S )Nc                     | dz  |dz  z   }t          j        ||           }t          j        |          |z  }t          j        |          |z
  t          j        |          t          j        |          z
  z  S )zAn electric dipole potential V.r   )rQ   r  r;  rW   rV   )r+   r,   r_sqrz  r'  s        r-   dipole_potentialz2test_tri_smooth_gradient.<locals>.dipole_potential  sb    !tad{
1a  F5MM$q		!q		"&)) 344r/      rc   r   r  r   r   Fr  .r   r   r   r  equalz0.8)r  rO   rP   g{Gz?hot)ro   rP   rP   rP   )r  cmap
linewidthsr   rm   bluegy&1|?r   rO  )unitsscalezorderr  width	headwidth
headlength)rQ   rS   r<  r  r  r;  r  r=  r   r   rH   r  r   r   r  r  r!  r#  r+   r,   r   r   gca
set_aspectr  r[   mpl	colormapsr  quiver)r  r  r  r  r  r  r+   r,   VrI   r  r  r  tciExEyE_normr  r  s                      r-   test_tri_smooth_gradientr    s   5 5 5 HGJK
D'22E[AbeGX>>>FYvc2:o.a@@@F
111add7OOOruX~%OOO	rvf~~	&&((A	rvf~~	&&((AAA1%%F
OOBHQv/05515==v/05515==? ? ! " " "
 $V,,G#0010==Hk 
#FQB
/
/C\\&(FH--FBXb"F JLLLGII!!!Ke$$$$Yr2t$$F=DN8[d2224 4 4 4 Jvx2f9biQfbR9 9 9 9 9 9r/   c                  |   t          j        g d          } t          j        dddt          j        d          z  ddg          }t          j        g dg dg d	gt           j        
          }t          j        g dt          
          }t          j        | |||          }t          j        |          }t          |j	        ddg           t          |
                    d          t           j                            dddt          j        d          z   z  t           j        g|                     t          j        g d          } t          j        g d          }t          j        g dgt           j        
          }t          j        | ||          }t          j        |          }t          |
                                t          j        dg                     d}d }t          j        dd|dz             } t          j         || d           || d                    \  } }|                                 } |                                }t          j        | |t#          |dz                       }t          j        |          }|                    d          }t          j        dt          
          }	g d}
d|	|
<   t)          ||	           t          j        dt          
          }d|d<   |                    |           |                    d          }g d}d|	|<   t)          ||	           d S )NrO   rP   r   rO   ro   rO   r   r   r  rP   r   r   r   r   FFTr   r   gV͞^&?F)rescalero   )rO   rP   ro   )rP   rO  r  r   c                 Z    t          j        |           |z  t          j        |           z  S rv   )rQ   r%  sign)r+   r   s     r-   powerztest_tritools.<locals>.power  s!    vayy!|BGAJJ&&r/   r   r   r      )r   r   r   r   r   r   r   r         "   #   ~                                    TP   ),   -   >   ?   N   O   r  Q   R   S   b   r@   t   u   )rQ   r   sqrtr   boolr   r   TriAnalyzerr   scale_factorscircle_ratiosr  masked_arraynanrS   rR   rT   r$  get_flat_tri_maskr   r   rH   )r+   r,   r   r   rI   analyserr3  r  	mask_flat
verif_maskcorners_indexcenter_indexs               r-   test_tritoolsr    s    	&&&''A
"b#bgbkk/3344A)))YYY			:"(KKKI8(((555D1id;;;F''Hh4q-6HIIIu--
CR^!4bf=tDDF F F
 	A
###$$A)))BH555I1i00F''Hh4466"GGG 	
A' ' ' 	CQqS!!A;uuQ||UU1d^^44DAq			A			A10B1Q30G0GHHHF''H**3//I#T***JG G GM $J}y*--- 8Ct$$$DDH
OOD**3//IMMML#J|y*-----r/   c                     d} d}t          j        dd| dz             }t          j        ||          \  }}|                                }|                                }t          j        d| dz  z  t
                    }d|| dz  d <   t          j        ||t          | dz             |          }t          j	        |          }|
                    |	          }|j        }|j        }	| |dz  z  }
t          j        dd|
dz             }t          j        ||          \  }}|                                }|                                }t          j        t          j        |d
|z   z  d          t          j        |d
|	z   z  d                    }t          |d           |j        }t          j        |j        |j                 d          dz  }t          j        |j        |j                 d          dz  }|                                } |||          }|j        |         }t          ||           t          j        g d          }t          j        g d          }t          j        ||g dg dg          t          j        ||g dg dg          g}t          j        |dz
  |dz
            }g }t-          d          D ]}t          j	        ||                   }|                    |d	          \  }}t          j        |j        |j        |f          d         }|t          j        |d d df         |d d df         f                   }||gz  }t5          |d         |d                    d S )Nr   r   r  rP   r   r   Tr   r  r   r   r   r   rO   rP   rO   rP   rO   rO   rP   rP   r   r   r   r   r   r  r   r   )rQ   rS   rR   rT   r   r  r   r   r$  r  refine_triangulationr+   r,   isinaroundr   r   r   r   r   r   r  rP  r  dstacklexsortr   )r3  r  r+   r,   r   rI   r  refi_triangx_refiy_refin_refix_verify_verifind1d	refi_maskrefi_tri_barycenter_xrefi_tri_barycenter_y
tri_finderrefi_tri_indicesrefi_tri_maskr'  xyz_datairefined_triang	refined_zxyzs                             r-   test_trirefiner3    s   	AF
CQqS!!A;q!DAq			A			A8AadF$'''DDAK10B1Q30G0G%)+ + +F$V,,G..f.==K]F]F]Fk#r6!8,,G{7G44GWmmooGmmooGGBIgs7{3Q77Ifc&j11557 7Eud###  IF;=1F#G()+ + +-/0F;=1F#G()+ + +-/0%%''J!z"7"79 9K 01My-000 	
'''((A

'''((A A			999'=>> A			999'=>>@F
S!c'""AH1XX  (33$+$8$81$8$E$E!	i)>+;YGHHK"*c!!!Q$iQQQT3445SEhqk8A;77777r/   r>  linearcubic)idsc                    t           j        d dd df         \  }}t          j        |                                d          }t          j        |                                d          }t          j        |          }t          j        ||          }t          j        |          } | ||          }|                    ||d           d S )Nr   )triinterpolatorr  )	rQ   mgridr  r  
zeros_liker   r   r  r  )r>  r+   r,   r'  r   r  r+  s          r-   test_trirefine_maskedr;  0  s     8BQBFDAq
	!))++q!!A
	!))++q!!A
aA

Q
"
"C$S))G\#q!!FF1=====r/   c                    g }t          | dz
            D ]P}t          | dz
            D ];}||| z  z   }|dz   || z  z   }||dz   | z  z   }|dz   |dz   | z  z   }||||g|||ggz  }<Qt          j        |t          j                  S )zU
    Return (2*(N-1)**2, 3) array of triangles to mesh (N, N)-point np.meshgrid.
    r   r   )rP  rQ   r   r   )r3  r   r/  jr   r   r   ds           r-   r$  r$  B  s     C1Q3ZZ * *qs 	* 	*AAaCA1!AQqS!GA11aAQ1I1ay))CC	* 8Crx((((r/   c                      t          j                                                    } t          j        g dg dg dg dg          }|                     |d          
J d            d S )Nr  r  r   r   r   zb-z(triplot should return the artist it adds)r   r   r   r   r   r  )r   rI   s     r-   test_triplot_returnr@  Q  s    		!	!	#	#B22299iii(* * *F ::fd##//2 0////r/   c                  L   t          j        g dg dg          } t          j        |           rJ t          j        | dd          }t          j        |          sJ t          j        g d          }t          j        g d          }t          j        |||           }t          j        |||          }t          j        |          }t          j        |          }|                    d	          }|                    d	          }	t          |j        |	j                   d S )
Nr  )r   r   r   TF)r   order)g(\?gzG?gQ?g{Gz?)gQ@@gzGA@gQA@gףp=
A@r   r  )	rQ   r   	isfortranr   r   r  r  r   r   )

triangles1
triangles2r+   r,   triang1triang2refiner1refiner2fine_triang1fine_triang2s
             r-   ,test_trirefiner_fortran_contiguous_trianglesrM  [  s    999iii011J|J'''''*4s;;;J<
#####
)))**A
---..A Az22G Az22G%g..H%g..H000::L000::L|-|/EFFFFFr/   c                  8   t          j        ddd          } t          t           j        t          j        | |                     \  }}||dz
  k    |dk     z  |dk    z  }||         ||         }}t          j        d          }|t          j        |          z  |t          j        |          z  z
  }|t          j        |          z  |t          j        |          z  z   }t          j	        ||          }|j
        }d |_        |j
        }	t          ||	           d S )Nr  r   r  r   g333333g333333   )rQ   rS   maprT   rR   radiansr;  r=  r   r   rG   rY   r   )
xir+   r,   wrz  x1y1rI   qhull_neighborsown_neighborss
             r-   test_qhull_triangle_orientationrX  r  s    	RC	 	 BrxR,,--DAq	
QUq5y!QX.AQ41qAJrNNE	
26%==1RVE]]?	*B	
26%==1RVE]]?	*B B''F &O F$M66666r/   c                     t          j        g d          } t          j        dddt          j        d          z  ddg          }t          j        g dg dg d	gt           j        
          }t          j        g dt          
          }t          j        | |||          }t          j        |          }|                                 d S )Nr  rO   r   r   r  rP   r   r   r   r   r  r   )	rQ   r   r
  r   r  r   r   r  _get_compressed_triangulation)r+   r,   r   r   rI   r  s         r-   #test_trianalyzer_mismatched_indicesr[    s    
&&&''A
"b#bgbkk/3344A)))YYY			:"(KKKI8(((555D1id;;;F''H **,,,,,r/   c                      g d} g d}g d}t          j                     t          j        t                    5  t          j        | ||ddg           d d d            d S # 1 swxY w Y   d S )N)rO   rP   rP   )rO   rO   rP   )r   r   r
  rP   rO   )r   r   r3   rB   rC   tricontourf)r+   r,   r'  s      r-   "test_tricontourf_decreasing_levelsr^    s    AAAJLLL	z	"	" - -1a#s,,,- - - - - - - - - - - - - - - - - -s   A  A$'A$returnc                     ddl m}  t          j        t          d          5  t
          j                                         d d d            n# 1 swxY w Y   t          j        t          d          5  t
          j                            t          j	        g           t          j	        dg          t          j	        g g          dddd           d d d            n# 1 swxY w Y   t          j	        g d	t          j
        
          }t          j	        g dt          j
        
          }t          j        t          d          5  t
          j                            ||t          j	        ddgg          dddd           d d d            n# 1 swxY w Y   t          j	        g dgt          j        
          }t          j        t          d          5  t
          j                            |||t          j	        ddg          ddd           d d d            n# 1 swxY w Y   t          j        t          d          5  t
          j                            |||dt          j	        dgg          dd           d d d            n# 1 swxY w Y   t          j        t          d          5  t
          j                            |||ddt          j	        dgg          d           d d d            n# 1 swxY w Y   t
          j                            |||dddd          }t          j        t          d          5  |                    g            d d d            n# 1 swxY w Y   ddgd fD ]J}t          j        t          d          5  |                    |           d d d            n# 1 swxY w Y   K|                    t          j	        dg                     t          |                                t          j        d                     |                    d           t          |                                ddgddgddgg           t          j        t          d          5  t
          j                                         d d d            n# 1 swxY w Y   t          j        t          d          5  t
          j                            |t          j	        dg                     d d d            n# 1 swxY w Y   t          j	        g d          }t
          j                            ||          }t          j        t          d          5  |                    dd           d d d            n# 1 swxY w Y   t          j        t          d          5  t
          j                                         d d d            n# 1 swxY w Y   t
          j                            |          }t          j        t          d          5  |                    t          j	        dg          t          j	        ddg                     d d d            d S # 1 swxY w Y   d S )Nr   )_triz1__init__\(\): incompatible constructor arguments.r=   z,x and y must be 1D arrays of the same lengthr   r7   F)r   r   r   r   r:   z.triangles must be a 2D array of shape \(\?,3\)r   zCmask must be a 1D array with the same length as the triangles arrayz,edges must be a 2D array with shape \(\?,2\)zGneighbors must be a 2D array with the same shape as the triangles arrayr   zMz must be a 1D array with the same length as the triangulation x and y arraysT)r   r   r   z?z must be a 1D array with the same length as the x and y arraysz(filled contour levels must be increasingz*x and y must be array-like with same shape)
matplotlibra  r3   rB   r   r  r   rC   rQ   r   rQ  int_calculate_plane_coefficientsrH   r   	get_edgesemptyTriContourGeneratorcreate_filled_contourTrapezoidMapTriFinder	find_many)	ra  r+   r,   r   rI   r   r'  tcgr   s	            r-   test_internal_cpp_apirl    s	    
F
H 
H 
H ! ! 	   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
 
M
O 
O 
O & &rx||RXqc]]BHbTNNBPRTV$	& 	& 	&& & & & & & & & & & & & & & &
 	"*---A
"*---A	C
E 
E 
E L L 	q!RX1vh%7%7RUKKKL L L L L L L L L L L L L L L
 8YYYKrw///D	%
& 
& 
& L L 	q!T28QF+;+;RUKKK	L L L L L L L L L L L L L L L 
M
O 
O 
O K Kq!T2rx!EJJJK K K K K K K K K K K K K K K 
%
& 
& 
& L L 	q!T2r28bTF3C3CUKKK	L L L L L L L L L L L L L L L X##Aq$BEBBF	2
3 
3 
3 0 0 	++B///	0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Q " "])* * * 	" 	" OOD!!!		" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" OOBHdV$$%%%v''))28F+;+;<<<
OOBv''))QFQFQF+CDDD 
F
H 
H 
H ' ' 	$$&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' '
 
T
V 
V 
V < < 	$$VRXqc]];;;< < < < < < < < < < < < < < <
 	A
(
&
&vq
1
1C	I
K 
K 
K ( (!!!Q'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (
 
F
H 
H 
H ) ) 	&&((() ) ) ) ) ) ) ) ) ) ) ) ) ) )
 ..v66I	K
M 
M 
M = =BHaSMM28QF+;+;<<<= = = = = = = = = = = = = = = = = =s   AAA3ACC!$C!;FFF:HH!$H!:J		JJ/:K55K9<K9 M""M&)M&N22N6	9N6	5R  R$'R$4TT
T
"VV	V	+WWW>Y&&Y*-Y*c                     t          j        g d          } t          j        g d          }d}t          j        | |          }t          j        | |z   ||z             }t	          |j                  t	          |j                  k    sJ d S )N)r   r   r   r   r   )r   r   r   r   r   g    _B)rQ   r   r   r   rU   r   )r+   r,   offsetrI   triang_offsets        r-   test_qhull_large_offsetrp    s    

$$$%%A

$$$%%AF1%%F&q6z1v:>>Mv  C(?$@$@@@@@@@r/   c            	      D   g d} g d}t          j        | |          }t          j                     t	          j        t          d          5  t          j        |dddt          j	        g           d d d            n# 1 swxY w Y   t	          j        t          d          5  t          j        |dddt          j	         g           d d d            n# 1 swxY w Y   t	          j        t          d          5  t          j        |dddt          j
        g           d d d            n# 1 swxY w Y   t	          j        t          d          5  t          j        |t          j                            g d	g d
                     d d d            d S # 1 swxY w Y   d S )Nr   r   zCz array must not contain non-finite values within the triangulationr=   r   r   r   z9z must not contain masked points within the triangulation)r   r   r   r   )r   r   r   r   r   )r   r   r   r   r3   rB   rC   r]  rQ   infr  r  r   )r+   r,   rI   s      r-   test_tricontour_non_finite_zrs    s   AA1%%FJLLL	z *K 
L 
L 
L 3 3Aq"& 12223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 
z *K 
L 
L 
L 4 4Aq26' 23334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
z *K 
L 
L 
L 3 3Aq"& 12223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 
z *D 
E 
E 
E N NLLL||| L LMMMN N N N N N N N N N N N N N N N N NsH   $A<<B B "%CCC9$D))D-0D-9FFFc                     g d} g d}g d}t          j                    \  }}|                    | ||          }|                    | ||          }|j        |j        k    sJ |                    ||          }|j        |j        k    sJ d S )N)rO   r   rP   )rO   rP   rO   )rP   ro   r   )r   r   r]  r  _contour_generator)r+   r,   r'  r   r   tcs1tcs2tcs3s           r-   test_tricontourset_reusery    s     	AAAlnnGC>>!Q""D==Aq!!D"d&=======q!!D"d&=======r/   c                     g d}g d}g dg}|                                                      |||d           |                                                     |||d           d S )Nr9   r:   r   z--)ls)	linestyle)r   r  )fig_testfig_refr+   r,   datas        r-   test_triplot_with_lsr  ,  sw    		A		AII;D1dt444q!TT:::::r/   c                     g d} g d}g dg}t          j                    \  }}|                    | ||d          \  }}|                                \  }}|dgk    sJ t	          |          dk    sJ |d         |u sJ d S )Nr9   r:   r   label)r  r   r   )r   r   r  get_legend_handles_labelsrU   )	r+   r,   r  r   r   linesmarkershandleslabelss	            r-   test_triplot_labelr  5  s    		A		AII;DlnnGCZZ1d'Z::NE72244OGVgYw<<11:r/   c                  <   g d} g d}t          j        | |          }t          j                    \  }}|                    |g ddg          }|                                }t          |          dk    sJ ddgddgddgg}t          |d         j        |           t          |d         j
        g d	           t          |d                             d
          |g           |                    |g ddg          }|                                }t          |          dk    sJ ddgddgddgddgddgg}t          |d         j        |           t          |d         j
        g d           t          |d                                         |g           d S )Nr   rN   rN   r   r   r   r   rN   rN   r   r   r   r   r   r   r   r  r   r   r   rt   F)closed_onlyr   r   r   r   r   r   r   r   r   r   r  )r   r   r   r   r  	get_pathsrU   r   verticesr   codesto_polygonsr+   r,   rI   rq  r   cspathsexpected_verticess           r-   test_tricontour_pathr  A  s   AA1%%FLNNEAr 
vu	=	=BLLNNEu::????Q!Q!Q0eAh/1BCCCuQx~yyy111a//2C1DF F F 
vu	=	=BLLNNEu::????Q!Q!Q!Q!Q@eAh/1BCCCuQx~'7'7'7888eAh22447H6IJJJJJr/   c                     g d} g d}t          j        | |          }t          j                    \  }}|                    |g dddg          }|                                }t          |          dk    sJ ddgddgddgddgddgg}t          |d	         j        |           t          |d	         j
        g d
           t          |d	                                         |g           |                    |g dddg          }|                                }t          |          dk    sJ dd	gddgd	dgd	d	gdd	gg}t          |d	         j        |           t          |d	         j
        g d
           t          |d	                                         |g           |                    |g dddg          }|                                }t          |          dk    sJ d	d	gdd	gddgd	dgd	d	gddgddgddgddgddgg
}t          |d	         j        |           t          |d	         j
        g d           t          |d	                                         t          j        |dg                     d S )Nr  r  r  r   r   r  r   r   r   r  r  r   g      rN   )
r   r   r   r   r  r   r   r   r   r  rM   )r   r   r   r   r]  r  rU   r   r  r   r  r  rQ   splitr  s           r-   test_tricontourf_pathr  [  s   AA1%%FLNNEAr 
c
	C	CBLLNNEu::????Q!Q!Q!Q!Q@eAh/1BCCCuQx~'7'7'7888eAh22447H6IJJJ 
c
	C	CBLLNNEu::????Q!Q!Q!Q!Q@eAh/1BCCCuQx~'7'7'7888eAh22447H6IJJJ 
s	D	DBLLNNEu::????Q!Q!Q!Q!QQ!Q!Q!Q!QAeAh/1BCCCuQx~'G'G'GHHHeAh2244bh?PSTRU6V6VWWWWWr/   )r_  N)DnumpyrQ   numpy.testingr   r   r   numpy.ma.testutilsr  	testutilsr"  r3   rb  r  matplotlib.pyplotpyplotr   matplotlib.trir   r   matplotlib.pathr   matplotlib.testing.decoratorsr   r   r
   r;   rE   rK   ra   rk   rr   r4   r5   rw   r   r   r   r   r   r   r  r6  rY  ru  r  r  r  r  r  r  r3  r   r!  r;  r$  r@  rM  rX  r[  r^  rl  rp  rs  ry  r  r  r  r  r7   r/   r-   <module>r     s      F F F F F F F F F F # # # # # # # # #                              O O O O O O O O' ' ' ' ' ' ' ':  / / /(" " ".'H 'H 'HTA A A(   HS1#JVaV YY			YY			+++,
" 
 
! !
 
!
*F *F *FZ #$%%  &%6* * *<* * *	= 	= 	=1 1 1d. d. d.N\6 \6 \6~SG SG SGlKF KF KF\H H H4;5 ;5 ;5|ZM ZM ZMz ./TuMMM#I #I NM#IL ,-4UKKK/9 /9 LK/9h5. 5. 5.p58 58 58p 435&0  2 2> >	2 2>) ) )3 3 3G G G.7 7 7.
- 
- 
-- - -X= X= X= X=vA A AN N N0> > > ; ; ;	 	 	K K K4 X  X  X  X  Xr/   