
    |Le                      d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZmZmZ d dlmZ 	 d dlZd dlZd	d
lmZ n# e$ r	 dZdZdZY nw xY w G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z  G d de          Z! G d de          Z" G d d e          Z# G d! d"e          Z$ G d# d$e          Z%d% Z&ed&             Z'd' Z(d( Z)d) Z*d* Z+d+ Z,d, Z-d- Z.d. Z/d/ Z0d0 Z1d1 Z2d2 Z3dS )3    )annotationsN)memoize)Glyph)_build_map_onto_pixel_for_line_clipt)
_PointLike)isnullisrealngjit)cuda   )	cuda_argsc                      e Zd ZdZd Zed             Zed             Zd Zed             Z	ed             Z
d Zd	 Zd
S )_AreaToLineLikez%Shared methods between Point and Linec                0    || _         || _        || _        d S Nxyy_stack)selfr   r   r   s       6lib/python3.11/site-packages/datashader/glyphs/area.py__init__z_AreaToLineLike.__init__   s        c                    dS N    r   s    r   ndimsz_AreaToLineLike.ndims   s    qr   c                *    | j         | j        | j        fS r   r   r   s    r   inputsz_AreaToLineLike.inputs    s    --r   c                h   t          |j        t          | j                                     st	          d          t          |j        t          | j                                     st	          d          t          |j        t          | j                                     st	          d          d S )Nzx must be realzy must be realzy_stack must be real or None)r
   measurestrr   
ValueErrorr   r   r   	in_dshapes     r   validatez_AreaToLineLike.validate$   s    i'DF455 	=-...	)#df++677 	=-...	)#dl*;*;<== 	=;<<<	= 	=r   c                    | j         S r   r   r   s    r   x_labelz_AreaToLineLike.x_label,   	    vr   c                    | j         S r   r   r   s    r   y_labelz_AreaToLineLike.y_label0   r-   r   c                *    | j         | j        | j        fS r   r   r   s    r   required_columnsz _AreaToLineLike.required_columns4       vtvt|++r   c                l    |                      || j                           }|                     |          S r   )_compute_boundsr   maybe_expand_boundsr   dfboundss      r   compute_x_boundsz _AreaToLineLike.compute_x_bounds7   s/    %%bj11''///r   N)__name__
__module____qualname____doc__r   propertyr    r"   r)   r,   r0   r2   r:   r   r   r   r   r      s        //  
   X . . X.= = =   X   X, , ,0 0 0 0 0r   r   c                  D    e Zd ZdZd Zed             Zed             ZdS )AreaToZeroAxis0zA filled area glyph.
    The area to be filled is the region from the line defined by ``x`` and
    ``y`` and the y=0 line

    Parameters
    ----------
    x, y
        Column names for the x and y coordinates of each vertex.
    c                    |                      || j                           }t          |d         d          t          |d         d          f}|                     |          S Nr   r   )r5   r   minmaxr6   r7   s      r   compute_y_boundsz AreaToZeroAxis0.compute_y_boundsG   sY    %%bj11 VAY""Cq	1$5$55 ''///r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          |d         d          t          |d         d          f}                     |                               |          fS )Nc           	        t          j        t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  gg          S r   )nparraynanminr   valuesitemnanmaxr   r8   r   s    r   <lambda>z5AreaToZeroAxis0.compute_bounds_dask.<locals>.<lambda>T   s    "(Ibj'((--//Ibj'((--//Ibj'((--//Ibj'((--//	51 42 +
 +
 r   r   r   r      map_partitionscomputerI   rK   rN   rD   rE   r6   r   ddfr	x_extents	y_extentss   `    r   compute_bounds_daskz#AreaToZeroAxis0.compute_bounds_daskQ          
  
  
  
  
 799 	
 Ia1g&&	!AAAqD'(:(::	Ia1g&&	!AAAqD'(:(::	 	!a((#ilA*>*>>	((33((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rat          |t          j                  rG                    |          }                    |          }t          |j                            }n|         j        }|         j        }} ||||||	|
|||||g|R   d S Nr   r   shapecudf
isinstance	DataFrameto_cupy_arrayr   rL   )aggsr8   vtr9   
plot_startsxtxsytyxminxmaxyminymaxaggs_and_colsxsys	do_extend
extend_cpuextend_cudainfor   x_namey_names                    r   extendz-AreaToZeroAxis0._build_extend.<locals>.extends   s   NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''F33''F33'	"((;(;<		Z&Z&&	IBBdD$B &3     r   T)expand_aggs_and_colsr   _build_draw_trapezoid_y _build_extend_area_to_zero_axis0r   r   )r   x_mappery_mapperrv   append_antialias_stage_2_antialias_stage_2_funcsr{   map_onto_pixeldraw_trapezoid_yry   rt   ru   rw   rx   s   `  `       @@@@r   _build_extendzAreaToZeroAxis0._build_extendd   s      $88@@7(KK2N$8
 
 #C2#
 #

K 	 	 	 	 	 	 	 	 	 	 	( r   Nr;   r<   r=   r>   rF   r   rZ   r   r   r   r   rA   rA   <   sc         0 0 0 5 5 W5$ " " W" " "r   rA   c                  D    e Zd ZdZd Zed             Zed             ZdS )AreaToLineAxis0a  A filled area glyph
    The area to be filled is the region from the line defined by ``x`` and
    ``y[0]`` and the line defined by ``x`` and ``y[1]``.

    Parameters
    ----------
    x
        Column names for the x and y coordinates of each vertex.
    y
        List or tuple of length two containing the column names of the
        y-coordinates of the two curves that define the area region.
    c                   |                      || j                           }|                      || j                           }t          |d         |d                   t	          |d         |d                   f}|                     |          S rC   )r5   r   r   rD   rE   r6   )r   r8   bounds0bounds1r9   s        r   rF   z AreaToLineAxis0.compute_y_bounds   s{    &&r$&z22&&r$,'788 WQZ,,c'!*gaj.I.II ''///r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          |d         |d                   t          |d         |d                   f}                     |                               |          fS )Nc                   t          j        t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  t          j        | j                 j                                                  gg          S r   )	rI   rJ   rK   r   rL   rM   rN   r   r   rO   s    r   rP   z5AreaToLineAxis0.compute_bounds_dask.<locals>.<lambda>   s    "(Ibj'((--//Ibj'((--//Ibj'((--//Ibj'((--//Ib&-..3355Ib&-..335557 48 +
 +
 r   r   r   r   rQ         rR   )r   rV   rW   rX   
y0_extents
y1_extentsrY   s   `      r   rZ   z#AreaToLineAxis0.compute_bounds_dask   s?     
  
  
  
   799 	
 Ia1g&&	!AAAqD'(:(::	YqAw''1QQQT7););;
YqAw''1QQQT7););;
 A
166A
1668	 ((33((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rwt          |t          j                  r]                    |          }                    |          }                    |          }t          |j                            }n)|         j        }|         j        }|         j        }} ||||||	|
||||||g|R   d S r^   r_   )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   ys0ys1rs   rt   ru   rv   r   rw   rx   y_stack_names                     r   ry   z-AreaToLineAxis0._build_extend.<locals>.extend   s"   NBB%+"D$d 44DGM"1",=#>#>>M 	'
2t~66 	'''F33((V44((\::'	"((;(;<		Z&j'&-&	IBBdD$BS+8     r   rz   )r{   r   r|    _build_extend_area_to_line_axis0r   r   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   rw   rx   r   s   `  `       @@@@@r   r   zAreaToLineAxis0._build_extend   s      $88@@7(KK2N$8
 
 #C2#
 #

K |	 	 	 	 	 	 	 	 	 	 	 	* r   Nr   r   r   r   r   r      sc         	0 	0 	0 5 5 W5* # # W# # #r   r   c                  ~    e Zd Zd Zed             Zed             Zd Zd Zd Z	e
d             Ze
d             Zd	S )
AreaToZeroAxis0Multic                    t          fd| j        D                       st          d          t          fd| j        D                       st          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r
   r$   r%   .0xcolr(   s     r   
<listcomp>z1AreaToZeroAxis0Multi.validate.<locals>.<listcomp>   /    LLLTF9,SYY788LLLr   x columns must be realc                ^    g | ])}t          j        t          |                             *S r   r   r   ycolr(   s     r   r   z1AreaToZeroAxis0Multi.validate.<locals>.<listcomp>   /    III$	)#d))455IIIr   y columns must be real)allr   r&   r   r'   s    `r   r)   zAreaToZeroAxis0Multi.validate   s    LLLLTVLLLMM 	75666IIII$&IIIK K 	75666	7 	7r   c                    dS Nr   r   r   s    r   r,   zAreaToZeroAxis0Multi.x_label       sr   c                    dS Nr   r   r   s    r   r0   zAreaToZeroAxis0Multi.y_label   r   r   c                     | j         | j        z   S r   r   r   r   s    r   r2   z%AreaToZeroAxis0Multi.required_columns       vr   c                      fd j         D             }t          | \  }}                     t          |          t	          |          f          S )Nc                F    g | ]}                     |                   S r   r5   r   r   r8   r   s     r   r   z9AreaToZeroAxis0Multi.compute_x_bounds.<locals>.<listcomp>   ;     ( ( ( ++BqE22 ( ( (r   r   zipr6   rD   rE   r   r8   bounds_listminsmaxess   ``   r   r:   z%AreaToZeroAxis0Multi.compute_x_bounds   f    ( ( ( ( ( $( ( (;'e''TCJJ(?@@@r   c                      fd j         D             }t          | \  }}t          dt          |                    }t          dt          |                    }                     ||f          S )Nc                F    g | ]}                     |                   S r   r   r   r   r8   r   s     r   r   z9AreaToZeroAxis0Multi.compute_y_bounds.<locals>.<listcomp>   r   r   r   )r   r   rD   rE   r6   )r   r8   r   r   r   mnmxs   ``     r   rF   z%AreaToZeroAxis0Multi.compute_y_bounds   s    ( ( ( ( ( $( ( (;'e CIICJJ''R111r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          d|d                   t          d|d                   f}                     |                               |          fS )Nc           	     P    t          j        t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   rI   rK   rL   rM   r   cr8   s     r   r   zNAreaToZeroAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  5    FFF!ryA..3355FFFr   c                r    g | ]3}t          j        |         j                                                  4S r   rI   rN   rL   rM   r   s     r   r   zNAreaToZeroAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToZeroAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>	  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToZeroAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>
  r   r   rI   rJ   rK   r   rN   r   rO   s   `r   rP   z:AreaToZeroAxis0Multi.compute_bounds_dask.<locals>.<lambda>      "(IFFFFtvFFFGGIFFFFtvFFFGGIFFFFtvFFFGGIFFFFtvFFFGG	5I 4J +
 +
 r   r   r   r   rQ   rR   rU   s   `    r   rZ   z(AreaToZeroAxis0Multi.compute_bounds_dask         
  
  
  
  
 799 	
 Ia1g&&	!AAAqD'(:(::	Ia1g&&	!AAAqD'(:(::	 9Q<((#a1*>*>>	((33((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j        d fd	}
|
S )NTc                "   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rat          |t          j                  rG                    |          }                    |          }t          |j                            }nb|j        d d t                    f                                         }|j        d d t                    f                                         }} ||||||	|
|||||g|R   d S r^   	r`   ra   rb   rc   rd   r   loclistto_numpyre   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   r   x_namesy_namess                    r   ry   z2AreaToZeroAxis0Multi._build_extend.<locals>.extend%  s4   NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''G44''G44'	"((;(;<		VAAAtG}},-6688VAAAtG}},-6688&	IBBdD$B%2     r   rz   )r{   r   r|   &_build_extend_area_to_zero_axis0_multir   r   r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   r   r   s   `  `       @@@@r   r   z"AreaToZeroAxis0Multi._build_extend  s      $88@@7(KK2N$8
 
 #I2#
 #

K &&	 	 	 	 	 	 	 	 	 	 	& r   Nr;   r<   r=   r)   r?   r,   r0   r2   r:   rF   r   rZ   r   r   r   r   r   r      s        7 7 7   X   X  A A A2 2 2 5 5 W5$ ! ! W! ! !r   r   c                  ~    e Zd Zd Zed             Zed             Zd Zd Zd Z	e
d             Ze
d             Zd	S )
AreaToLineAxis0Multic                "   t          fd| j        D                       st          d          t          fd| j        D                       st          d          t          fd| j        D                       st          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z1AreaToLineAxis0Multi.validate.<locals>.<listcomp>=  r   r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z1AreaToLineAxis0Multi.validate.<locals>.<listcomp>@  r   r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z1AreaToLineAxis0Multi.validate.<locals>.<listcomp>C  s?     + + + 	)#d))455 + + +r   y_stack columns must be real)r   r   r&   r   r   r'   s    `r   r)   zAreaToLineAxis0Multi.validate<  s    LLLLTVLLLMM 	=5666IIII$&IIIK K 	=5666+ + + +!\+ + +, , 	= ;<<<	= 	=r   c                    dS r   r   r   s    r   r,   zAreaToLineAxis0Multi.x_labelG  r   r   c                    dS r   r   r   s    r   r0   zAreaToLineAxis0Multi.y_labelK  r   r   c                0    | j         | j        z   | j        z   S r   r   r   s    r   r2   z%AreaToLineAxis0Multi.required_columnsO      v--r   c                      fd j         D             }t          | \  }}                     t          |          t	          |          f          S )Nc                F    g | ]}                     |                   S r   r   r   s     r   r   z9AreaToLineAxis0Multi.compute_x_bounds.<locals>.<listcomp>S  r   r   r   r   s   ``   r   r:   z%AreaToLineAxis0Multi.compute_x_boundsR  r   r   c                      fd j          j        z   D             }t          | \  }}                     t	          |          t          |          f          S )Nc                F    g | ]}                     |                   S r   r   r   s     r   r   z9AreaToLineAxis0Multi.compute_y_bounds.<locals>.<listcomp>Y  ;     7 7 7 ++BqE22 7 7 7r   r   r   r   r6   rD   rE   r   s   ``   r   rF   z%AreaToLineAxis0Multi.compute_y_boundsX  m    7 7 7 7 7 $ 57 7 7;'e''TCJJ(?@@@r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d ddgf                   t          j        |d d ddgf                   f}                     |                               |          fS )Nc                    t          j        t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>c  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>d  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>e  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>f  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>g  5    LLL!ryA..3355LLLr   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zNAreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>h  r   r   rI   rJ   rK   r   rN   r   r   rO   s   `r   rP   z:AreaToLineAxis0Multi.compute_bounds_dask.<locals>.<lambda>b      "(IFFFFtvFFFGGIFFFFtvFFFGGIFFFFtvFFFGGIFFFFtvFFFGGILLLLt|LLLMMILLLLt|LLLMM5
 4 +
 +
 r   r   r   r   r   rQ   r   rS   rT   rI   rK   rN   r6   rU   s   `    r   rZ   z(AreaToLineAxis0Multi.compute_bounds_dask_         
  
  
  
   799 	
 Ia1g&&	!AAAqD'(:(::	IaAq6	l++RYqQF|-D-DD	((33((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rwt          |t          j                  r]                    |          }                    |          }                    |          }t          |j                            }n|j        d d t                    f                                         }|j        d d t                    f                                         }|j        d d t                    f                                         }} ||||||	|
||||||g|R   d S r^   r   )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   r   r   rs   rt   ru   rv   r   r   r   y_stack_namess                     r   ry   z2AreaToLineAxis0Multi._build_extend.<locals>.extend  st   NBB%+"D$d 44DGM"1",=#>#>>M 	'
2t~66 	'''G44((W55((];;'	"((;(;<		VAAAtG}},-6688fQQQW-.7799fQQQ] 3 334==??&	IBBdD$BS+8     r   rz   )r{   r   r|   &_build_extend_area_to_line_axis0_multir   r   r   r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   r   r   r   s   `  `       @@@@@r   r   z"AreaToLineAxis0Multi._build_extendr  s      $88@@7(KK2N$8
 
 #I2#
 #

K &&	 	 	 	 	 	 	 	 	 	 	 	* r   Nr   r   r   r   r   r   ;  s        	= 	= 	=   X   X. . .A A AA A A 5 5 W5$ # # W# # #r   r   c                  ~    e Zd Zd Zd Zed             Zed             Zd Zd Z	e
d             Ze
d             Zd	S )
AreaToZeroAxis1c                   t          fd| j        D                       st          d          t          fd| j        D                       st          d          t	          fd| j        D                       }t          |          dk    rt          d          t	          fd| j        D                       }t          |          dk    rt          d	          d S )
Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z,AreaToZeroAxis1.validate.<locals>.<listcomp>  ?     ( ( ( 9,SYY788 ( ( (r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z,AreaToZeroAxis1.validate.<locals>.<listcomp>  ?     * * * Y.s4yy9:: * * *r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r$   r%   r   s     r   	<genexpr>z+AreaToZeroAxis1.validate.<locals>.<genexpr>  E        4  4$( !* 1#d)) <  4  4  4  4  4  4r   r   &x columns must have the same data typec              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z+AreaToZeroAxis1.validate.<locals>.<genexpr>  r
  r   &y columns must have the same data type)r   r   r&   r   setlen)r   r(   unique_x_measuresunique_y_measuress    `  r   r)   zAreaToZeroAxis1.validate  sS    ( ( ( ( $( ( ( ) ) 	75666 * * * *"&&* * * + + 	75666  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF &%r   c                     | j         | j        z   S r   r   r   s    r   r2   z AreaToZeroAxis1.required_columns  r   r   c                    dS r   r   r   s    r   r,   zAreaToZeroAxis1.x_label  r   r   c                    dS r   r   r   s    r   r0   zAreaToZeroAxis1.y_label  r   r   c                     t          fd j        D                       } fd|D             }t          | \  }}                     t	          |          t          |          f          S )Nc              3  (   K   | ]}|         V  d S r   r   r   xlabelr8   s     r   r	  z3AreaToZeroAxis1.compute_x_bounds.<locals>.<genexpr>  '      33&2f:333333r   c                :    g | ]}                     |          S r   r   r   r   r   s     r   r   z4AreaToZeroAxis1.compute_x_bounds.<locals>.<listcomp>  '    AAAdt++D11AAAr   tupler   r   r6   rD   rE   r   r8   rq   r   r   r   s   ``    r   r:   z AreaToZeroAxis1.compute_x_bounds  t    3333DF33333AAAAbAAA;'e''TCJJ(?@@@r   c                    t          fd j        D                       } fd|D             }t          | \  }}t          dt          |                    }t	          dt	          |                    }                     ||f          S )Nc              3  (   K   | ]}|         V  d S r   r   )r   ylabelr8   s     r   r	  z3AreaToZeroAxis1.compute_y_bounds.<locals>.<genexpr>  r  r   c                :    g | ]}                     |          S r   r   )r   r   r   s     r   r   z4AreaToZeroAxis1.compute_y_bounds.<locals>.<listcomp>  r  r   r   )r  r   r   rD   rE   r6   )r   r8   rr   r   r   r   r   r   s   ``      r   rF   z AreaToZeroAxis1.compute_y_bounds  s    3333DF33333AAAAbAAA;'e CIICJJ''R111r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          d|d                   t          d|d                   f}                     |                               |          fS )Nc           	     P    t          j        t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToZeroAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToZeroAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToZeroAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToZeroAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   r   rO   s   `r   rP   z5AreaToZeroAxis1.compute_bounds_dask.<locals>.<lambda>  r   r   r   r   r   rQ   rR   rU   s   `    r   rZ   z#AreaToZeroAxis1.compute_bounds_dask  r   r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j        d fd	}
|
S )NTc                T   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          r{t          |t          j                  ra                    |t                              }                    |t                              }t          |j                            }nb|j        d d t                    f                                         }|j        d d t                    f                                         }} ||||||	|
||||g
|R   d S r^   	r`   ra   rb   rc   rd   r   r   r   r   r   s                    r   ry   z-AreaToZeroAxis1._build_extend.<locals>.extend  s=   NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''4==99''4==99'	"((;(;<		VAAAtG}},-6688VAAAtG}},-6688&	IBBdD$BAN     r   rz   )r{   r   r|   ._build_extend_area_to_zero_axis1_none_constantr   r   r   s   `  `       @@@@r   r   zAreaToZeroAxis1._build_extend  s      $88@@7(KK2N$8
 
 #Q2#
 #

K &&	 	 	 	 	 	 	 	 	 	 	$ r   Nr;   r<   r=   r)   r2   r?   r,   r0   r:   rF   r   rZ   r   r   r   r   r  r    s        G G G$     X   XA A A
2 
2 
2 5 5 W5$ ! ! W! ! !r   r  c                  ~    e Zd Zd Zd Zed             Zed             Zd Zd Z	e
d             Ze
d             Zd	S )
AreaToLineAxis1c                   t          fd| j        D                       st          d          t          fd| j        D                       st          d          t          fd| j        D                       st          d          t          fd| j        D                       }t          |          dk    rt          d	          t          fd
| j        D                       }t          |          dk    rt          d          t          fd| j        D                       }t          |          dk    rt          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z,AreaToLineAxis1.validate.<locals>.<listcomp>  r  r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z,AreaToLineAxis1.validate.<locals>.<listcomp>  r  r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z,AreaToLineAxis1.validate.<locals>.<listcomp>  s?     0 0 0 Y.s4yy9:: 0 0 0r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z+AreaToLineAxis1.validate.<locals>.<genexpr>  r
  r   r   r  c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z+AreaToLineAxis1.validate.<locals>.<genexpr>  r
  r   r  c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z+AreaToLineAxis1.validate.<locals>.<genexpr>  sM       &@ &@*. '0&7D		&B &@ &@ &@ &@ &@ &@r   ,y_stack columns must have the same data type)r   r   r&   r   r   r  r  )r   r(   r  r  unique_y_stack_measuress    `   r   r)   zAreaToLineAxis1.validate  s     ( ( ( ( $( ( ( ) ) 	=5666 * * * *"&&* * * + + 	=5666 0 0 0 0"&,0 0 0 1 1 	=;<<<  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF"% &@ &@ &@ &@26,&@ &@ &@ #@ #@&''!++KLLL ,+r   c                0    | j         | j        z   | j        z   S r   r   r   s    r   r2   z AreaToLineAxis1.required_columns  r   r   c                    dS r   r   r   s    r   r,   zAreaToLineAxis1.x_label!  r   r   c                    dS r   r   r   s    r   r0   zAreaToLineAxis1.y_label%  r   r   c                     t          fd j        D                       } fd|D             }t          | \  }}                     t	          |          t          |          f          S )Nc              3  (   K   | ]}|         V  d S r   r   r  s     r   r	  z3AreaToLineAxis1.compute_x_bounds.<locals>.<genexpr>*  r  r   c                :    g | ]}                     |          S r   r   r  s     r   r   z4AreaToLineAxis1.compute_x_bounds.<locals>.<listcomp>,  r  r   r  r  s   ``    r   r:   z AreaToLineAxis1.compute_x_bounds)  r   r   c                      fd j          j        z   D             }t          | \  }}                     t	          |          t          |          f          S )Nc                F    g | ]}                     |                   S r   r   r   s     r   r   z4AreaToLineAxis1.compute_y_bounds.<locals>.<listcomp>2  r   r   r   r   s   ``   r   rF   z AreaToLineAxis1.compute_y_bounds1  r   r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d ddgf                   t          j        |d d ddgf                   f}                     |                               |          fS )Nc                    t          j        t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp><  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>=  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>?  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>@  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zIAreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>A  r   r   r   rO   s   `r   rP   z5AreaToLineAxis1.compute_bounds_dask.<locals>.<lambda>;  r   r   r   r   r   r   rQ   r   r   rU   s   `    r   rZ   z#AreaToLineAxis1.compute_bounds_dask8  r   r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rt          |t          j                  r                    |t                              }                    |t                              }                    |t                              }t          |j                            }n|j        d d t                    f                                         }|j        d d t                    f                                         }|j        d d t                    f                                         }} ||||||	|
|||||g|R   d S r^   r-  )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   y_stacksrs   rt   ru   rv   r   r   r   r   s                     r   ry   z-AreaToLineAxis1._build_extend.<locals>.extendZ  s   NBB%+"D$d 44DGM"1",=#>#>>M 	'
2t~66 	'''4==99''4==99--bm1D1DEE'	"((;(;<		VAAAtG}},-6688VAAAtG}},-66886!!!T-%8%8"89BBDD&	IBBdD$B#0     r   rz   )r{   r   r|   ._build_extend_area_to_line_axis1_none_constantr   r   r   r   s   `  `       @@@@@r   r   zAreaToLineAxis1._build_extendK  s      $88@@7(KK2N$8
 
 #Q2#
 #

K &&	 	 	 	 	 	 	 	 	 	 	 	* r   Nr/  r   r   r   r1  r1    s        M M M4. . .   X   XA A AA A A 5 5 W5$ # # W# # #r   r1  c                  L    e Zd Zd Zd Zd Zed             Zed             ZdS )AreaToZeroAxis1XConstantc                    t          fd| j        D                       st          d          t          fd| j        D                       }t	          |          dk    rt          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z5AreaToZeroAxis1XConstant.validate.<locals>.<listcomp>t  r   r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z4AreaToZeroAxis1XConstant.validate.<locals>.<genexpr>w  r
  r   r   r  )r   r   r&   r  r  )r   r(   r  s    ` r   r)   z!AreaToZeroAxis1XConstant.validates      LLLLTVLLLMM 	75666  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF &%r   c                    | j         S r   r/   r   s    r   r2   z)AreaToZeroAxis1XConstant.required_columns|  	    vr   c                    t          j        | j                  }t          j        | j                  }|                     ||f          S r   rI   rK   r   rN   r6   r   argsx_minx_maxs       r   r:   z)AreaToZeroAxis1XConstant.compute_x_bounds  <    	$&!!	$&!!''777r   c                "    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}                                                      |          fS )Nc                     t          j        t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToZeroAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToZeroAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   )rI   rJ   rK   r   rN   rO   s   `r   rP   z>AreaToZeroAxis1XConstant.compute_bounds_dask.<locals>.<lambda>  h    "(IFFFFtvFFFGGIFFFFtvFFFGG5I 4J +
 +
 r   r   r   rS   rT   rI   rK   rN   r:   r6   r   rV   rW   rY   s   `   r   rZ   z,AreaToZeroAxis1XConstant.compute_bounds_dask  s       
  
  
  
   799 	

 Ia1g&&	!AAAqD'(:(::	%%''((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rXt          |t          j                  r>                    |t                              }t          |j                            }n2|j        d d t                    f                                         }} ||||||	|
|||g
|R   d S r^   r-  )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rr   rs   rt   ru   rv   r   x_valuesr   s                   r   ry   z6AreaToZeroAxis1XConstant._build_extend.<locals>.extend  s    NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''4==99'	"((;(;<		VAAAtG}},-6688&	IBBdD$"  -     r   rz   )r{   r   r|   +_build_extend_area_to_zero_axis1_x_constantr   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   rg  r   s   `  `       @@@@r   r   z&AreaToZeroAxis1XConstant._build_extend  s      $88@@7(KK2N$8
 
 #N2#
 #

K 6&	 	 	 	 	 	 	 	 	 	 	$ r   N	r;   r<   r=   r)   r2   r:   r   rZ   r   r   r   r   rP  rP  r  sz        G G G  8 8 8
 
5 
5 W
5     W     r   rP  c                  L    e Zd Zd Zd Zd Zed             Zed             ZdS )AreaToLineAxis1XConstantc                   t          fd| j        D                       st          d          t          fd| j        D                       st          d          t	          fd| j        D                       }t          |          dk    rt          d          t	          fd| j        D                       }t          |          dk    rt          d	          d S )
Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z5AreaToLineAxis1XConstant.validate.<locals>.<listcomp>  r  r   r   c                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z5AreaToLineAxis1XConstant.validate.<locals>.<listcomp>  s?     . . . 9,SYY788 . . .r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z4AreaToLineAxis1XConstant.validate.<locals>.<genexpr>  r
  r   r   r  c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z4AreaToLineAxis1XConstant.validate.<locals>.<genexpr>  sE       &: &:*. '0&7D		&B &: &: &: &: &: &:r   r9  )r   r   r&   r   r  r  )r   r(   r  r:  s    `  r   r)   z!AreaToLineAxis1XConstant.validate  sS    ( ( ( ( $( ( ( ) ) 	75666 . . . . $. . . / / 	=;<<<  4  4  4  4,0F 4  4  4 4 4 !!A%%EFFF"% &: &: &: &:26&&: &: &: #: #:&''!++KLLL ,+r   c                     | j         | j        z   S r   )r   r   r   s    r   r2   z)AreaToLineAxis1XConstant.required_columns  s    v$$r   c                    t          j        | j                  }t          j        | j                  }|                     ||f          S r   rX  rY  s       r   r:   z)AreaToLineAxis1XConstant.compute_x_bounds  r]  r   c                *    |                      fd                                          }t          j        |d d ddgf                   t          j        |d d ddgf                   f}                                                      |          fS )Nc           	     P    t          j        t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1XConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   )rI   rJ   rK   r   rN   r   rO   s   `r   rP   z>AreaToLineAxis1XConstant.compute_bounds_dask.<locals>.<lambda>  s    "(IFFFFtvFFFGGIFFFFtvFFFGGILLLLt|LLLMMILLLLt|LLLMM	5
 4 +
 +
 r   r   r   r   rQ   rc  rd  s   `   r   rZ   z,AreaToLineAxis1XConstant.compute_bounds_dask  s       
  
  
  
   799 	
 IaAq6	l++RYqQF|-D-DD	%%''((335 	5r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j         j        d fd	}
|
S )NTc                V   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          r{t          |t          j                  ra                    |t                              }                    |t                              }t          |j                            }nb|j        d d t                    f                                         }|j        d d t                    f                                         }} ||||||	|
||||g|R   d S r^   r-  )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rr   rM  rs   rt   ru   rv   r   rg  r   r   s                    r   ry   z6AreaToLineAxis1XConstant._build_extend.<locals>.extend  sG   NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''4==99--bm1D1DEE'	"((;(;<		VAAAtG}},-66886!!!T-%8%8"89BBDD&	IBBdD$"h *7     r   rz   )r{   r   r|   +_build_extend_area_to_line_axis1_x_constantr   r   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   rg  r   r   s   `  `       @@@@@r   r   z&AreaToLineAxis1XConstant._build_extend  s      $88@@7(KK2N$8
 
 #N2#
 #

K 6&	 	 	 	 	 	 	 	 	 	 	 	( r   Nri  r   r   r   rk  rk    sz        M M M&% % %8 8 8
 5 5 W5 # # W# # #r   rk  c                  L    e Zd Zd Zd Zd Zed             Zed             ZdS )AreaToZeroAxis1YConstantc                    t          fd| j        D                       st          d          t          fd| j        D                       }t	          |          dk    rt          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z5AreaToZeroAxis1YConstant.validate.<locals>.<listcomp>
  r   r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z4AreaToZeroAxis1YConstant.validate.<locals>.<genexpr>  r
  r   r   r  r   r   r&   r  r  r   r(   r  s    ` r   r)   z!AreaToZeroAxis1YConstant.validate	  rT  r   c                    | j         S r   r+   r   s    r   r2   z)AreaToZeroAxis1YConstant.required_columns  rV  r   c                    t          j        | j                  }t          j        | j                  }|                     ||f          S r   )rI   rK   r   rN   r6   r   rZ  y_miny_maxs       r   rF   z)AreaToZeroAxis1YConstant.compute_y_bounds  r]  r   c                "    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}                     |                                           fS )Nc                     t          j        t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToZeroAxis1YConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToZeroAxis1YConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>  r   r   rI   rJ   rK   r   rN   rO   s   `r   rP   z>AreaToZeroAxis1YConstant.compute_bounds_dask.<locals>.<lambda>  rb  r   r   r   rS   rT   rI   rK   rN   r6   rF   r   rV   rW   rX   s   `   r   rZ   z,AreaToZeroAxis1YConstant.compute_bounds_dask         
  
  
  
   799 	

 Ia1g&&	!AAAqD'(:(::	((33%%'') 	)r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rlt          |t          j                  rR                    |t                              }t          j                  }t          |j                            }n4|j	        d d t                    f         
                                }}} ||||||	|
||||g
|R   d S r^   r`   ra   rb   rc   rd   r   cpasarrayr   r   r   )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   r   r   y_valuess                    r   ry   z6AreaToZeroAxis1YConstant._build_extend.<locals>.extend6  s   NBB%+"D$d 44DGM"1",=#>#>>M '
2t~66 '''4==99Z))'	"((;(;<		VAAAtG}},-6688&	IBBdD$B '     r   rz   )r{   r   r|   +_build_extend_area_to_zero_axis1_y_constantr   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   r   r  s   `  `       @@@@r   r   z&AreaToZeroAxis1YConstant._build_extend'  s      $88@@7(KK2N$8
 
 #N2#
 #

K &6	 	 	 	 	 	 	 	 	 	 	( r   N	r;   r<   r=   r)   r2   rF   r   rZ   r   r   r   r   r}  r}    sz        G G G  8 8 8
 
) 
) W
) " " W" " "r   r}  c                  L    e Zd Zd Zd Zd Zed             Zed             ZdS )AreaToLineAxis1YConstantc                    t          fd| j        D                       st          d          t          fd| j        D                       }t	          |          dk    rt          d          d S )Nc                ^    g | ])}t          j        t          |                             *S r   r   r   s     r   r   z5AreaToLineAxis1YConstant.validate.<locals>.<listcomp>O  r   r   r   c              3  L   K   | ]}j         t          |                   V  d S r   r  r   s     r   r	  z4AreaToLineAxis1YConstant.validate.<locals>.<genexpr>R  r
  r   r   r  r  r  s    ` r   r)   z!AreaToLineAxis1YConstant.validateN  rT  r   c                    | j         S r   r+   r   s    r   r2   z)AreaToLineAxis1YConstant.required_columnsW  rV  r   c                (   t          t          j        | j                  t          j        | j                            }t          t          j        | j                  t          j        | j                            }|                     ||f          S r   )rD   rI   rK   r   r   rE   rN   r6   r  s       r   rF   z)AreaToLineAxis1YConstant.compute_y_boundsZ  sh    BIdf%%ry'>'>??BIdf%%ry'>'>??''777r   c                "    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}                     |                                           fS )Nc                     t          j        t          j         fdj        D                       t          j         fdj        D                       gg          S )Nc                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1YConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>c  r   r   c                r    g | ]3}t          j        |         j                                                  4S r   r   r   s     r   r   zRAreaToLineAxis1YConstant.compute_bounds_dask.<locals>.<lambda>.<locals>.<listcomp>d  r   r   r  rO   s   `r   rP   z>AreaToLineAxis1YConstant.compute_bounds_dask.<locals>.<lambda>b  rb  r   r   r   r  r  s   `   r   rZ   z,AreaToLineAxis1YConstant.compute_bounds_dask_  r  r   c                                           |          }t          ||          }t          |||          }	t          |	|          \   j         j         j        d fd	}
|
S )NTc                   |\  }}}}|\  }	}
}}|  || d         j         d d                   z   }t          rt          |t          j                  rf                    |t                              }t          j                  }t          j                  }t          |j                            }n6|j	        d d t                    f         
                                }}}} ||||||	|
|||||g|R   d S r^   r  )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   ysvrs   rt   ru   rv   r   r   y_stack_valuesr  s                     r   ry   z6AreaToLineAxis1YConstant._build_extend.<locals>.extend{  s)   NBB%+"D$d 44DGM"1",=#>#>>M 	'
2t~66 	'''4==99Z))j00'	"((;(;<		VAAAtG}},-6688$&	IBBdD$B ,     r   rz   )r{   r   r|   +_build_extend_area_to_line_axis1_y_constantr   r   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   ru   r   r  r  s   `  `       @@@@@r   r   z&AreaToLineAxis1YConstant._build_extendl  s      $88@@7(KK2N$8
 
 #N2#
 #

K &6	 	 	 	 	 	 	 	 	 	 	 	, r   Nr  r   r   r   r  r  M  sz        G G G  8 8 8
 
) 
) W
) $ $ W$ $ $r   r  c                  R    e Zd Zd Zd Zd Zd Zed             Zed             Z	dS )AreaToZeroAxis1Raggedc                0   	 ddl m} n# t          $ r t          d           }Y nw xY wt	          |t          | j                           |          st          d          t	          |t          | j                           |          st          d          d S )Nr   RaggedDtypex must be a RaggedArrayy must be a RaggedArray)	datashader.datatypesr  ImportErrortyperb   r%   r   r&   r   r   r(   r  s      r   r)   zAreaToZeroAxis1Ragged.validate  s    	%8888888 	% 	% 	%t**KKK	% )CKK0+>> 	86777Ic$&kk2K@@ 	86777	8 	8   	 %%c                    | j         | j        fS r   r   r   s    r   r2   z&AreaToZeroAxis1Ragged.required_columns  s    vtv~r   c                    |                      || j                 j        j                  }|                     |          S r   r5   r   rJ   
flat_arrayr6   r7   s      r   r:   z&AreaToZeroAxis1Ragged.compute_x_bounds  5    %%bj&6&ABB''///r   c                    |                      || j                 j        j                  }t	          |d         d          t          |d         d          f}|                     |          S rC   )r5   r   rJ   r  rD   rE   r6   r7   s      r   rF   z&AreaToZeroAxis1Ragged.compute_y_bounds  s]    %%bj&6&ABB VAY""Cq	1$5$55''///r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d df                   t          j        |d d df                   f}t          |d         d          t          |d         d          f}                     |                               |          fS )Nc           	        t          j        t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  gg          S r   )rI   rJ   rK   r   r  rM   rN   r   rO   s    r   rP   z;AreaToZeroAxis1Ragged.compute_bounds_dask.<locals>.<lambda>  s    "(Ibj&1227799Ibj&1227799Ibj&1227799Ibj&1227799	5; 4< +
 +
 r   r   r   r   rQ   rR   rU   s   `    r   rZ   z)AreaToZeroAxis1Ragged.compute_bounds_dask  r[   r   c                    |                      |          }t          ||          }t          |||          }	t          |	|          | j        | j        dfd	}
|
S )NTc                    |\  }}}}|\  }	}
}}|         j         }|         j         }|  || d         j        d d                   z   } |||||	|
||||g
|R   d S r^   rL   r`   )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rp   rv   perform_extend_cpurw   rx   s                   r   ry   z3AreaToZeroAxis1Ragged._build_extend.<locals>.extend  s    NBB%+"D$dF"BF"B 44DGM"1",=#>#>>MBBdD$B '     r   rz   )r{   r   r|   '_build_extend_area_to_zero_axis1_raggedr   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   r  rw   rx   s      `       @@@r   r   z#AreaToZeroAxis1Ragged._build_extend  s      $88@@7(KK2N$8
 
 E2
 
 	 	 	 	 	 	 	 	 	 r   N
r;   r<   r=   r)   r2   r:   rF   r   rZ   r   r   r   r   r  r    s        	8 	8 	8  0 0 00 0 0 5 5 W5$   W  r   r  c                  R    e Zd Zd Zd Zd Zd Zed             Zed             Z	dS )AreaToLineAxis1Raggedc                   	 ddl m} n# t          $ r t          d           }Y nw xY wt	          |t          | j                           |          st          d          t	          |t          | j                           |          st          d          t	          |t          | j	                           |          st          d          d S )Nr   r  r  r  zy_stack must be a RaggedArray)
r  r  r  r  rb   r%   r   r&   r   r   r  s      r   r)   zAreaToLineAxis1Ragged.validate  s    	%8888888 	% 	% 	%t**KKK	% )CKK0+>> 	>6777Ic$&kk2K@@ 	>6777Ic$,&7&78+FF 	><===	> 	>r  c                *    | j         | j        | j        fS r   r   r   s    r   r2   z&AreaToLineAxis1Ragged.required_columns  r3   r   c                    |                      || j                 j        j                  }|                     |          S r   r  r7   s      r   r:   z&AreaToLineAxis1Ragged.compute_x_bounds  r  r   c                H   |                      || j                 j        j                  }|                      || j                 j        j                  }t          |d         |d         d          t          |d         |d         d          f}|                     |          S rC   )r5   r   rJ   r  r   rD   rE   r6   )r   r8   bounds_ybounds_y_stackr9   s        r   rF   z&AreaToLineAxis1Ragged.compute_y_bounds  s    ''46
(8(CDD--t|"-/ / hqk>!#4a88hqk>!#4a88: ''///r   c                    |                      fd                                          }t          j        |d d df                   t          j        |d d df                   f}t          j        |d d ddgf                   t          j        |d d ddgf                   f}                     |                               |          fS )Nc                   t          j        t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  t          j        | j                 j        j                                                  gg          S r   )	rI   rJ   rK   r   r  rM   rN   r   r   rO   s    r   rP   z;AreaToLineAxis1Ragged.compute_bounds_dask.<locals>.<lambda>  s    "(Ibj&1227799Ibj&1227799Ibj&1227799Ibj&1227799Ib&,788==??Ib&,788==??5
 4 +
 +
 r   r   r   r   r   rQ   r   r   rU   s   `    r   rZ   z)AreaToLineAxis1Ragged.compute_bounds_dask   r   r   c                    |                      |          }t          ||          }t          |||          }	t          |	|          | j        | j        | j        dfd	}
|
S )NTc                    |\  }}}}|\  }	}
}}|         j         }|         j         }|         j         }|  || d         j        d d                   z   } |||||	|
|||||g|R   d S r^   r  )re   r8   rf   r9   rg   rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rM  rp   rt   rv   rw   rx   r   s                    r   ry   z3AreaToLineAxis1Ragged._build_extend.<locals>.extend"  s    NBB%+"D$dF"BF"B,'.H 44DGM"1",=#>#>>MJBBdD$B $1     r   rz   )r{   r   r|   '_build_extend_area_to_line_axis1_raggedr   r   r   )r   r~   r   rv   r   r   r   r{   r   r   ry   rt   rw   rx   r   s      `       @@@@r   r   z#AreaToLineAxis1Ragged._build_extend  s      $88@@7(KK2N$8
 
 =2
 

 |	 	 	 	 	 	 	 	 	 	 r   Nr  r   r   r   r  r    s        > > >, , ,0 0 0	0 	0 	0 5 5 W5$   W  r   r  c                d     t           d             t           | fd                        }|S )z^Specialize a plotting kernel for drawing a trapezoid with two
    sides parallel to the y-axisc                    | dk     r|dk    p| |k    o||k    }t          dt          ||                     }t          dt          |dz   |                    }|||fS )z-Utility function to compute clamped y-indicesr   r   )rE   rD   )ystartiystopiymaxiout_of_boundsclamped_ystarticlamped_ystopis         r   clamp_y_indicesz0_build_draw_trapezoid_y.<locals>.clamp_y_indices8  su     "A+5&A+ ?!E/=fo 	 aUG!4!455 RUQY!7!788o~==r   c                :   t          |	|
||||||||
  
        \	  }	}
}}}}}}}|rdS  /|||||||||	|
  
        \  }} /|||||||||	|
  
        \  }} /|||||||||
|
  
        \  }} /|||||||||
|
  
        \  }} /||||||||||
  
        \  }}||z
  }|dk    |dk     z
  }||z
  } | dk    | dk     z
  }!||z
  }"|"dk    |"dk     z
  }#|p|}|r~ .|||          \  }$}%}&|dk     p||k    }'|$s|'rn\|%|&k    r|s -| ||%g|R   nH|%}(|%|&k     |&|%k     z
  })|sd|&|)z   cxk    r	|dz   k    rn n|&|)z  }&|(|&k    r -| ||(g|R   |(|)z  }(|(|&k    |p|}*|dk    r|*s .|||          \  }$}%}&|dk     p||k    }'|$s|'rn\|%|&k    r|s -| ||%g|R   nH|%}(|%|&k     |&|%k     z
  })|sd|&|)z   cxk    r	|dz   k    rn n|&|)z  }&|(|&k    r -| ||(g|R   |(|)z  }(|(|&k    dS t          |          dz  }t          |           dz  } t          |"          dz  }"d| z  |z
  }+d|"z  |z
  },||k    r|+dk    r#|+s|dk    r|+d|z  z  }+||!z  }|+dk    r|+|dk    |+d| z  z  }+|,dk    r#|,s|dk    r|,d|z  z  },||#z  }|,dk    r|,|dk    |,d|"z  z  },||z  }|dk     p||k    }'|'r| .|||          \  }$}%}&|$rn\|%|&k    r|s -| ||%g|R   nH|%}(|%|&k     |&|%k     z
  })|sd|&|)z   cxk    r	|dz   k    rn n|&|)z  }&|(|&k    r -| ||(g|R   |(|)z  }(|(|&k    ||k    dS dS )a	  Draw a filled trapezoid that has two sides parallel to the y-axis

        Such a trapezoid is defined by two x coordinates (x0 for the left
        edge and x1 for the right parallel edge) and four y-coordinates
        (y0 for top left vertex, y1 for bottom left vertex, y2 for the bottom
        right vertex and y3 for the top right vertex).

                                          (x1, y3)
                                      _ +
                        (x0, y0)  _--   |
                                +       |
                                |       |
                                |       |
                                +       |
                        (x0, y1)  -     |
                                    -   |
                                      - |
                                        +
                                          (x1, y2)

        In a proper trapezoid (as drawn above), y0 >= y1 and y3 >= y2 so that
        edges do not intersect. This function also handles the case where
        y1 < y0 or y2 < y3, which results in a crossing edge.

        The trapezoid is filled using a vertical scan line algorithm where the
        start and stop bins are calculated by what amounts to a pair of
        Bresenham's line algorithms, one for the top edge and one for the
        bottom edge.

        Bins in the line connecting (x0, y1) and (x1, y2) are not filled if
        the `stacked` argument is set to True. This way stacked trapezoids
        will not have any overlapping bins.

        Parameters
        ----------
        x0, x1: float
            x-coordinate indices of the start and stop edge of the trapezoid
        y0, y1, y2, y3: float
            y-coordinate indices of the four corners of the trapezoid
        xmin, xmax, ymin, ymax: float
            The minimum and maximum allowable x and y value respectively.
            The trapezoid will be clipped to these values.
        i: int
            Group index
        trapezoid_start: bool
            If True, the filled trapezoid will include the (x0, y0) to (x0, y1)
            edge. Otherwise this edge will not be included.
        stacked: bool
            If False, the filled trapezoid will include the
            (x0, y1) to (x1, y2) edge. Otherwise this edge will not
            be included.
        Nr   r  r   r   )_skip_or_clip_trapezoid_yabs)0irh   ri   rj   rk   rl   rm   rn   ro   x0x1y0y1y2y3trapezoid_startstackedrp   skipclipped_startclipped_endx0iy0i_y1ix1iy2iy3ixmaxir  dxixdy0iy0dy1iy1y_ooby_starty_stopx_oobr   iyclippederror0error1r   r  r   s0                                                r   r   z1_build_draw_trapezoid_y.<locals>.draw_trapezoid_yN  s   v &BBBdD$@ @ 	ABBBm[  	F!>BD$dB
 
S  BD$dB
 
3 ">BD$dB
 
S  BD$dB
 
3 &~BD$dD$
 
u 3Y1fa 
 CiQw37#CiQw37# *:] 	%4_S#u%E%E"E7F!G*sU{E  F""7"q#w777777 &6G+;< !2"#A#A#A#A	#A#A#A#A#A bLF6kkF1c15}5555GA 6kk
  .;7777%4_S#u%E%E"E7F!G*sU{E   F""7"q#w777777 &6G+;< !2"#A#A#A#A	#A#A#A#A#A bLF6kkF1c15}5555GA 6kk F WWq[#hhl#hhlS2S2Sjj A++6+R!VV!b& s
 A++6+R!VV a#gF A++6+R!VV!b& s
 A++6+R!VV a#gF 2IC !G*sU{E   &5_S#u%E%E"E7F F""7"q#w777777 &6G+;< !2"#A#A#A#A	#A#A#A#A#A bLF6kkF1c15}5555GA 6kki Sjjjjjjr   r   )r   r   r{   r   r  s   ``  @r   r|   r|   4  sj     > > U>* V V V V V V  UVp r   c
           	        d}
t          |           sKt          |          s<t          |          s-t          |          st          |          st          |          rd}
||	k    r||	k    r||	k    r||	k    s||k     r#||k     r||k     r||k     rd}
dx}}| ||||||
||f	S d\  }}|| z
  }||z
  }||z
  }t          | | |z
  ||          \  }}}|sd}
t          ||| z
  ||          \  }}}|sd}
|dk     rd}| ||z  z   }|||z  z   }|||z  z   }nd}|dk    rd}| ||z  z   } |||z  z   }|||z  z   }nd}| ||||||
||f	S )NFT)r   r   r   r   )r	   r   )r  r  r  r  r  r  rl   rm   rn   ro   r  r  r  t0t1r  r  r  accepts                      r   r  r  +  s    D 	r

 2JJ2JJ 2JJ 2JJ	
 2JJ  
drDyyR$YY299$YY299drDyy&++2r2r2t]KGG FB	bB
r'C
r'C RCdB33NBF Br	2r22NBF  
Avv"r'\"s(]"s(]	Avv"r'\"s(]"s(]r2r2r4CCr   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                   d}|
|          }|
| dz            }||          }d}d}|| dz            }| dk    r|	n/t          |
| dz
                     pt          || dz
                     } | ||||||||||||||||g|R   d S )NFr           r   r	   )r  rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   r  r  r  r  r  r  r  r  r   s                        r   perform_extendz8_build_extend_area_to_zero_axis0.<locals>.perform_extendj  s     UAYUAY)*a::"2a!e9--B1q5	1B1B 	 	r2r2tT4BBOW	
?L	
 	
 	
 	
 	
 	
r   c                t    |	j         d         }t          |dz
            D ]} || |||||||||	|
g|R   dS )^Aggregate filled area along a line formed by
        ``xs`` and ``ys``, filled to the y=0 liner   r   Nr`   range)rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   nrowsr  r  s                 r   rt   z4_build_extend_area_to_zero_axis0.<locals>.extend_cpu~  st     uqy!! 	? 	?AN1b"b"dD$%r2?0=? ? ? ? ?	? 	?r   c                    t          j        d          }||	j        d         dz
  k     r || |||||||||	|
g|R   d S d S Nr   r   r   gridr`   )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   r  r  s                r   ru   z5_build_extend_area_to_zero_axis0.<locals>.extend_cuda  st     IaLLrx{QN2r2r4tTB%2      r   r   r   jitr   r{   rt   ru   r  s   `   @r   r}   r}   g  s     
 
 
 
  U
$ 	? 	? 	? 	?  U	? 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                P   |
|          }|
| dz            }||          }||          }|| dz            }|| dz            }| dk    r|	nGt          |
| dz
                     p/t          || dz
                     pt          || dz
                     }d} | ||||||||||||||||g|R   d S Nr   r   Tr  )r  rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  r  r  r  r  r  r  r   s                         r   r  z8_build_extend_area_to_line_axis0.<locals>.perform_extend  s     UAYVVQZQZ)*a::"2a!e9-- /"3q1u:../"3q1u:.. 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c                v    |	j         d         }t          |dz
            D ]} || |||||||||	|
|g|R   dS )zuAggregate filled area between the line formed by
        ``xs`` and ``ys0`` and the line formed by ``xs`` and ``ys1``r   r   Nr
  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  r  s                  r   rt   z4_build_extend_area_to_line_axis0.<locals>.extend_cpu  sw     uqy!! 	 	AN2r2r4tTBS+8    	 	r   c                    t          j        d          }||	j        d         dz
  k     r || |||||||||	|
|g|R   d S d S r  r  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  s                 r   ru   z5_build_extend_area_to_line_axis0.<locals>.extend_cuda  sv     IaLLrx{QN2r2r4tTBS+8      r   r  r  s   `   @r   r   r     s     
 
 
 
  U
&      U 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                   || |f         }|| dz   |f         }|| |f         }d}d}|| dz   |f         }| dk    r|
n3t          || dz
  |f                   pt          || dz
  |f                   }d} | ||||||||	||||||||g|R   d S Nr   r  r   Fr  )r  jrh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   r  r  r  r  r  r  r  r  r   s                         r   r  z>_build_extend_area_to_zero_axis0_multi.<locals>.perform_extend  s     1XAq\1XAq\)*a::"2a!eQh<00 1"2a!eQh<00 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c                    |	j         \  }}t          |          D ],}t          |dz
            D ]} ||| |||||||||	|
g|R   -dS r	  r   Nr
  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   r  ncolsr  r  r  s                   r   rt   z:_build_extend_area_to_zero_axis0_multi.<locals>.extend_cpu  s     xuu 	C 	CA519%% C Cq!RRT4t)2rC4AC C C C CC	C 	Cr   c                    t          j        d          \  }}||	j        d         dz
  k     r(||	j        d         k     r ||| |||||||||	|
g|R   d S d S d S Nr   r   r   r  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   rr   rp   r  r  r  s                 r   ru   z;_build_extend_area_to_zero_axis0_multi.<locals>.extend_cuda  s     y||1rx{Q1rx{??N1b"b"dD$B%2      ??r   r  r  s   `   @r   r   r     s     
 
 
 
  U
$ C C C C  UC 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                t   || |f         }|| dz   |f         }|| |f         }|| |f         }|| dz   |f         }|| dz   |f         }| dk    r|
nMt          || dz
  |f                   p3t          || dz
  |f                   pt          || dz
  |f                   }d} | ||||||||	||||||||g|R   d S r  r  )r  r  rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  r  r  r  r  r  r  r   s                          r   r  z>_build_extend_area_to_line_axis0_multi.<locals>.perform_extend  s    1XAq\AYAYQ]Q])*a::"2a!eQh<00 2"3q1uax=112"3q1uax=11 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c                    |	j         \  }}t          |          D ]-}t          |dz
            D ]} ||| |||||||||	|
|g|R   .dS r  r
  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  r  r  r  s                    r   rt   z:_build_extend_area_to_line_axis0_multi.<locals>.extend_cpu   s     xuu 	I 	IA519%% I Iq!RRT4t)2sCI:GI I I I II	I 	Ir   c                    t          j        d          \  }}||	j        d         dz
  k     r)||	j        d         k     r ||| |||||||||	|
|g|R   d S d S d S r!  r  )rh   ri   rj   rk   rl   rm   rn   ro   rg   rq   r   r   rp   r  r  r  s                  r   ru   z;_build_extend_area_to_line_axis0_multi.<locals>.extend_cuda0  s     y||1rx{Q1rx{??N1b"b"dD$BS+8      ??r   r  r  s   `   @r   r   r     s     
 
 
 
  U
& I I I I  UI 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                   |
| |f         }|
| |dz   f         }|| |f         }d}d}|| |dz   f         }|dk    p3t          |
| |dz
  f                   pt          || |dz
  f                   }d} | ||||||||	||||||||g|R   d S r  r  r  r  rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rp   r  r  r  r  r  r  r  r  r   s                        r   r  zF_build_extend_area_to_zero_axis1_none_constant.<locals>.perform_extendC  s     1X1q5\1X1q5\6 0!"QAX,//0!"QAX,// 	 r2r2tT4BBOW	
?L	
 	
 	
 	
 	
 	
r   c
                    |j         \  }}t          |          D ]+}t          |dz
            D ]} ||| |||||||||	g|
R   ,d S r   r
  rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rp   r  r  r  r  r  s                  r   rt   zB_build_extend_area_to_zero_axis1_none_constant.<locals>.extend_cpuZ      
 xuu 	 	A519%%  q"b"b$dD*    	 	r   c
                    t          j        d          \  }}||j        d         k     r*||j        d         dz
  k     r ||| |||||||||	g|
R   d S d S d S r!  r  rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rp   r  r  r  s                r   ru   zC_build_extend_area_to_zero_axis1_none_constant.<locals>.extend_cudag      
 y||1rx{??q28A;?22N1b"b"dD$B&      ?22r   r  r  s   `   @r   r.  r.  @       
 
 
 
  U
* 	 	 	 	  U	 
X     X {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                p   |
| |f         }|
| |dz   f         }|| |f         }|| |f         }|| |dz   f         }|| |dz   f         }|dk    pMt          |
| |dz
  f                   p3t          || |dz
  f                   pt          || |dz
  f                   }d} | ||||||||	||||||||g|R   d S r  r  r  r  rh   ri   rj   rk   rl   rm   rn   ro   rq   r   r   rp   r  r  r  r  r  r  r  r  r   s                         r   r  zF_build_extend_area_to_line_axis1_none_constant.<locals>.perform_extendy  s    1X1q5\AYAYAE]AE]6 1!"QAX,//1!#aQh-001 "#aQh-00 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c                    |j         \  }}t          |          D ],}t          |dz
            D ]} ||| |||||||||	|
g|R   -dS r  r
  rh   ri   rj   rk   rl   rm   rn   ro   rq   r   r   rp   r  r  r  r  r  s                   r   rt   zB_build_extend_area_to_line_axis1_none_constant.<locals>.extend_cpu  s     xuu 	 	A519%%  q"b"b$dDS#0    	 	r   c                    t          j        d          \  }}||j        d         k     r+||j        d         dz
  k     r ||| |||||||||	|
g|R   d S d S d S r!  r  rh   ri   rj   rk   rl   rm   rn   ro   rq   r   r   rp   r  r  r  s                 r   ru   zC_build_extend_area_to_line_axis1_none_constant.<locals>.extend_cuda       y||1rx{??q28A;?22N1b"b"dD$C,      ?22r   r  r  s   `   @r   rN  rN  v  s     
 
 
 
  U
.      U 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                
   |
|         }|
|dz            }|| |f         }d}d}|| |dz   f         }|dk    p1t          |
|dz
                     pt          || |dz
  f                   }d} | ||||||||	||||||||g|R   d S r  r  r(  s                        r   r  zC_build_extend_area_to_zero_axis1_x_constant.<locals>.perform_extend  s    
 UAY1X1q5\6 0!"QU),,0!"QAX,// 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c
                    |	j         \  }}t          |          D ]+}t          |dz
            D ]} ||| |||||||||	g|
R   ,d S r   r
  r*  s                  r   rt   z?_build_extend_area_to_zero_axis1_x_constant.<locals>.extend_cpu  r+  r   c
                    t          j        d          \  }}||	j        d         k     r*||	j        d         dz
  k     r ||| |||||||||	g|
R   d S d S d S r!  r  r-  s                r   ru   z@_build_extend_area_to_zero_axis1_x_constant.<locals>.extend_cuda  r.  r   r  r  s   `   @r   rh  rh    r/  r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                d   |
|         }|
|dz            }|| |f         }|| |f         }|| |dz   f         }|| |dz   f         }|dk    pKt          |
|dz
                     p3t          || |dz
  f                   pt          || |dz
  f                   }d} | ||||||||	||||||||g|R   d S r  r  r2  s                         r   r  zC_build_extend_area_to_line_axis1_x_constant.<locals>.perform_extend  s    UAYAYAYAE]AE]6 1!"QU),,1!#aQh-001 "#aQh-00 	 r2r2tT4BBOW	
?L	
 	
 	
 	
 	
 	
r   c                    |	j         \  }}t          |          D ],}t          |dz
            D ]} ||| |||||||||	|
g|R   -d S r   r
  r4  s                   r   rt   z?_build_extend_area_to_line_axis1_x_constant.<locals>.extend_cpu  s     yuu 	 	A519%%  q"b"b$dDS#0    	 	r   c                    t          j        d          \  }}||	j        d         k     r+||	j        d         dz
  k     r ||| |||||||||	|
g|R   d S d S d S r!  r  r6  s                 r   ru   z@_build_extend_area_to_line_axis1_x_constant.<locals>.extend_cuda  s     y||1sy|CIaL1$4 4 4N1b"b"dD$C,       4 4r   r  r  s   `   @r   r{  r{    s     
 
 
 
  U
, 
 
 
 
  U
 
X	 	 	 	  X	 {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                
   |
| |f         }|
| |dz   f         }||         }d}d}||dz            }|dk    p1t          |
| |dz
  f                   pt          ||dz
                     }d} | ||||||||	||||||||g|R   d S r  r  r(  s                        r   r  zC_build_extend_area_to_zero_axis1_y_constant.<locals>.perform_extend$  s     1X1q5\UAY6 -!"QAX,//-!"QU),, 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c
                    |j         \  }}t          |          D ]+}t          |dz
            D ]} ||| |||||||||	g|
R   ,d S r   r
  r*  s                  r   rt   z?_build_extend_area_to_zero_axis1_y_constant.<locals>.extend_cpu<  r+  r   c
                    t          j        d          \  }}||j        d         k     r*||j        d         dz
  k     r ||| |||||||||	g|
R   d S d S d S r!  r  r-  s                r   ru   z@_build_extend_area_to_zero_axis1_y_constant.<locals>.extend_cudaI  r.  r   r  r  s   `   @r   r  r  !  s     
 
 
 
  U
, 	 	 	 	  U	 
X     X {""r   c                     t           | fd                        t           |fd                        }t          j        |fd                        }||fS )Nc                X   |
| |f         }|
| |dz   f         }||         }||         }||dz            }||dz            }|dk    pIt          |
| |dz
  f                   p/t          ||dz
                     pt          ||dz
                     }d} | ||||||||	||||||||g|R   d S r  r  r2  s                         r   r  zC_build_extend_area_to_line_axis1_y_constant.<locals>.perform_extend[  s    1X1q5\VVQZQZ6 .!"QAX,//.!#a!e*--. "#a!e*-- 	 r2r2tT4BBOW	
 	
 	
 	
 	
 	
 	
r   c                    |j         \  }}t          |          D ],}t          |dz
            D ]} ||| |||||||||	|
g|R   -d S r   r
  r4  s                   r   rt   z?_build_extend_area_to_line_axis1_y_constant.<locals>.extend_cpuu  s     xuu 	 	A519%%  q"b"b$dDS#0    	 	r   c                    t          j        d          \  }}||j        d         k     r+||j        d         dz
  k     r ||| |||||||||	|
g|R   d S d S d S r!  r  r6  s                 r   ru   z@_build_extend_area_to_line_axis1_y_constant.<locals>.extend_cuda  r7  r   r  r  s   `   @r   r  r  X  s     
 
 
 
  U
0 
 
 
 
  U
 
X	 	 	 	  X	 {""r   c                H     fd}t           | fd                        |S )Nc
                h    |j         }|j        }|	j         }|	j        } | |||||||||||g|
R   d S r   start_indicesr  )rh   ri   rj   rk   rl   rm   rn   ro   rq   rr   rp   x_start_indsx_flaty_start_indsy_flat(perform_extend_area_to_zero_axis1_raggeds                  r   rt   z;_build_extend_area_to_zero_axis1_ragged.<locals>.extend_cpu  sk     ''00BD$d&,	
 	
 	
 	
 	
 	
 	
r   c                   t          |          }t          |	          }t          |          }d}||k     r||         }||dz
  k     r||dz            n|}|
|         }||dz
  k     r|
|dz            n|}t          ||z
  ||z
            }d}||dz
  k     r|	||z            }|	||z   dz            }|||z            }d}d}|||z   dz            }|dk    p5t          |	||z   dz
                     pt          |||z   dz
                     }d} || |||||||||||||||g|R   |dz  }||dz
  k     |dz  }||k     d S d S )Nr   r   r  Fr  rD   r	   ) rh   ri   rj   rk   rl   rm   rn   ro   rL  rM  rN  rO  rp   r  
x_flat_len
y_flat_lenr  	x_start_ix_stop_i	y_start_iy_stop_isegment_lenr  r  r  r  r  r  r  r  r  r   s                                   r   rP  zY_build_extend_area_to_zero_axis1_ragged.<locals>.perform_extend_area_to_zero_axis1_ragged  s    L!![[
[[
%ii$QI/0519}}QU++*H %QI/0519}}QU++*H h2&24 4K AkAo%%IM*IMA-.IM*IMA-.#$6 $E#)&Q1B*C#D#D$E#)&Q1B*C#D#D      r2r2tT4BBOW #    Q) kAo%%* FAG %iiiiiir   r  )r   r{   rt   rP  s   `  @r   r  r    sV    
 
 
 
 
 - - - -  U-^ r   c                H     fd}t           | fd                        |S )Nc                    |j         }|j        }|	j         }|	j        }|
j         }|
j        } | |||||||||||||g|R   d S r   rJ  )rh   ri   rj   rk   rl   rm   rn   ro   rq   r   r   rp   rL  rM  y0_start_indsy0_flaty1_start_indsy1_flat(perform_extend_area_to_line_axis1_raggeds                     r   rt   z;_build_extend_area_to_line_axis1_ragged.<locals>.extend_cpu  s~     ').).00BD$dL&7M7	 	 	 	 	 	 	r   c                B   t          |          }t          |	          }t          |          }t          |          }d}||k     rX||         }||dz
  k     r||dz            n|}|
|         }||dz
  k     r|
|dz            n|}||         }||dz
  k     r||dz            n|}t          ||z
  ||z
  ||z
            }d}||dz
  k     r|	||z            }|	||z   dz            }|||z            }|||z            }|||z   dz            } |||z   dz            }!|dk    pPt          |	||z   dz
                     p5t          |||z   dz
                     pt          |||z            dz
            }"d}# $|| |||||||||||| |!|"|#g|R   |dz  }||dz
  k     |dz  }||k     Vd S d S )Nr   r   TrR  )%rh   ri   rj   rk   rl   rm   rn   ro   rL  rM  r\  r]  r^  r_  rp   r  rS  y0_flat_leny1_flat_lenr  rU  rV  
y0_start_i	y0_stop_i
y1_start_i	y1_stop_irY  r  r  r  r  r  r  r  r  r  r   s%                                       r   r`  zY_build_extend_area_to_line_axis1_ragged.<locals>.perform_extend_area_to_line_axis1_ragged  sS    L!![[
'll'll%ii$QI/0519}}QU++*H 'q)J12UQYq1u--KI&q)J12UQYq1u--KI h2'*4'*46 6K AkAo%%IM*IMA-.Z!^,Z!^,Z!^a/0Z!^a/0#$6 $G#)&Q1B*C#D#D$G#)'*q.12D*E#F#F$G $*'*q.*AA*E#F#F     r2r2tT4BBOW #   
 Q' kAo%%( FAM %iiiiiir   r  )r   r{   rt   r`  s   `  @r   r  r    sV        $ 1 1 1 1  U1f r   )4
__future__r   numpyrI   toolzr   datashader.glyphs.glyphr   datashader.glyphs.liner   r   datashader.glyphs.pointsr   datashader.utilsr	   r
   r   numbar   ra   cupyr  transfer_functions._cuda_utilsr   r  r   rA   r   r   r   r  r1  rP  rk  r}  r  r  r  r|   r  r}   r   r   r   r.  rN  rh  r{  r  r  r  r  r   r   r   <module>rr     s   " " " " " "           ) ) ) ) ) ) I I I I I I I I / / / / / / 2 2 2 2 2 2 2 2 2 2      KKK:::::::   D	BIII$0 $0 $0 $0 $0e $0 $0 $0NK K K K Kj K K K\S S S S So S S SlX X X X X: X X Xv[ [ [ [ [? [ [ [|g g g g gj g g gTl l l l lo l l l^@ @ @ @ @ @ @ @FP P P P P P P PfB B B B B B B BJD D D D D D D DNI I I I IJ I I IXQ Q Q Q QO Q Q Qht t tn 8D 8D 8Dv1# 1# 1#h4# 4# 4#n3# 3# 3#l5# 5# 5#p3# 3# 3#l9# 9# 9#x3# 3# 3#l6# 6# 6#r4# 4# 4#n8# 8# 8#vC C CLJ J J J Js   A AA