
    |LeW                       d dl mZ d dlmZ d dlZd dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZ d dlZd dlZddlmZ dd	lmZmZmZmZmZ dd
lmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 	 d dl1m2Z2m3Z3 n# e4$ r d\  Z2Z3Y nw xY werd dl5m6Z6 dgZ7 ej8        e9          Z:eddddd            Z;d$dZ<d Z=d Z>d Z?d Z@d%dZAd  ZBd! ZCd" ZDd# ZEdS )&    )annotations)countN)TYPE_CHECKING)uniqueconcatpluckgetmemoizeliteral_unroll   )AntialiasCombination)SpecialColumnUsesCudaMutexbycategory_codessummary)isnullngjitnanmax_in_placenanmin_in_placenansum_in_placenanfirst_in_placenanlast_in_placenanmax_n_in_place_3dnanmax_n_in_place_4dnanmin_n_in_place_3dnanmin_n_in_place_4dnanfirst_n_in_place_3dnanfirst_n_in_place_4dnanlast_n_in_place_3dnanlast_n_in_place_4drow_min_in_placerow_min_n_in_place_3drow_min_n_in_place_4drow_max_in_placerow_max_n_in_place_3drow_max_n_in_place_4d)cuda_mutex_lockcuda_mutex_unlock)NN)UnzippedAntialiasStage2compile_componentsF)	antialiascudapartitionedc          	        t          t          |                     }t          t          t          fd|D                                           }fd|D             }rAt	          ||          \  }	rddl}
|
}nt          } |	|          }	t          |	|          }ndd}	d}fdt          ||          D             }t          t          t          d|                              }t          d |D                       }t          t          ||z                       }t          t          d	|                    }t          t          d
|                    }t          ||          }t          ||||          \  }}t          ||          }t          ||||          }t          ||           }d |D             }||||||	||fS )a]  Given an ``Aggregation`` object and a schema, return 5 sub-functions
    and information on how to perform the second stage aggregation if
    antialiasing is requested,

    Parameters
    ----------
    agg : Aggregation
        The expression describing the aggregation(s) to be computed.

    schema : DataShape
        Columns and dtypes in the source dataset.

    glyph : Glyph
        The glyph to render.

    antialias : bool
        Whether to render using antialiasing.

    cuda : bool
        Whether to render using CUDA (on the GPU) or CPU.

    partitioned : bool
        Whether the source dataset is partitioned using dask.

    Returns
    -------
    A tuple of the following:

    ``create(shape)``
        Function that takes the aggregate shape, and returns a tuple of
        initialized numpy arrays.

    ``info(df, canvas_shape)``
        Function that takes a dataframe, and returns preprocessed 1D numpy
        arrays of the needed columns.

    ``append(i, x, y, *aggs_and_cols)``
        Function that appends the ``i``th row of the table to the ``(x, y)``
        bin, given the base arrays and columns in ``aggs_and_cols``. This does
        the bulk of the work.

    ``combine(base_tuples)``
        Function that combines a list of base tuples into a single base tuple.
        This forms the reducing step in a reduction tree.

    ``finalize(aggs, cuda)``
        Function that is given a tuple of base numpy arrays and returns the
        finalized ``DataArray`` or ``Dataset``.

    ``antialias_stage_2``
        If using antialiased lines this is a tuple of the ``AntialiasCombination``
        values corresponding to the aggs. If not using antialiased lines then
        this is ``False``.

    ``antialias_stage_2_funcs``
        If using antialiased lines which require a second stage combine, this
        is a tuple of the three combine functions which are the accumulate,
        clear and copy_back functions. If not using antialiased lines then this
        is ``None``.

    ``column_names``
        Names of DataFrame columns or DataArray variables that are used by the
        agg.
    c              3  D   K   | ]}|                               V  d S N)_build_bases).0rr.   r/   s     3lib/python3.11/site-packages/datashader/compiler.py	<genexpr>z%compile_components.<locals>.<genexpr>i   s1      OOQq~~dK@@OOOOOO    c                @    g | ]}|                               S  )
out_dshape)r4   br-   r.   r/   schemas     r6   
<listcomp>z&compile_components.<locals>.<listcomp>j   s+    QQQaq||FIt[AAQQQr8   r   NFc                @    g | ]\  }}t          ||          S r:   )_get_call_tuples)r4   r<   dr-   r.   r/   r=   self_intersects      r6   r>   z&compile_components.<locals>.<listcomp>   sA     0 0 0!Q aFD)^[YY 0 0 0r8      c              3  6   K   | ]}|d          
|d          V  dS    Nr:   r4   cs     r6   r7   z%compile_components.<locals>.<genexpr>   s/      BB111A!A$1A1A1A1ABBr8         c                F    g | ]}|j         t          j        k    |j         S r:   )columnr   RowIndexrG   s     r6   r>   z&compile_components.<locals>.<listcomp>   s)    QQQah-:P.P.PAH.P.P.Pr8   )listtraverse_aggregationr   r   make_antialias_stage_2cupynp make_antialias_stage_2_functionszipr   make_createmake_append	make_infomake_combinemake_finalize)aggr=   glyphr-   r.   r/   redsbasesdshapesantialias_stage_2rQ   array_moduleantialias_stage_2_funcscallscolsnan_check_colstempscombine_tempscreateappendany_uses_cuda_mutexinfocombinefinalizecolumn_namesrB   s    ` ```                   @r6   r,   r,   $   s_   D $S))**D OOOOO$OOOOOPPQQEQQQQQQQ5QQQG  ',B4,O,O)) 	KKKLLL--l;;"BCTV[]aCN#P #P !"&0 0 0 0 0 0 0 0ug..0 0 0E uQ''((DBBBBBBBNtn,--..D q%!!Eq%))M..F"-eT5%"S"SFT4!455D5'5-DR]^^GUC{CCHQQdQQQL4(4EG^ r8   combinationr   zerofloatn_reductionboolcategoricalc                :   |r|dk    r[| t           j        t           j        fv r|rt          nt          S | t           j        t           j        fv r|rt          nt          S t          | t           j        k    r|rt          nt          S | t           j        k    r|rt          nt          S | t           j        k    r|rt          nt          S | t           j        k    r|rt           nt"          S t          |dk    rI| t           j        t           j        fv rt$          S | t           j        t           j        fv rt&          S t          | t           j        k    rt(          S | t           j        k    rt*          S | t           j        k    rt,          S | t           j        k    rt.          S t0          S )N)r   MAXLASTr(   r'   MINFIRSTr%   r$   NotImplementedErrorr   r   r   r   r    r   r"   r!   r&   r#   r   r   r   r   r   )rn   ro   rq   rs   s       r6   #_get_antialias_stage_2_combine_funcr{      s    ('2::379M9RSSS0;V,,AVV!5!9;O;U VVV0;V,,AVV))2666/:T++@TT 4 888/:T++@TT 4 :::1<X--BXX 4 9990;V,,AVV))
 2::379M9RSSS''!5!9;O;U VVV''))2666&& 4 888&& 4 :::(( 4 999''&&r8   c           
        | \  }}}}d t          ||||          D             }d |D             }	|	dd          dgz   }
i }t          |d<   t          |          D ]}|||j        <   d t	                      D             }g d}t          t          ||	|
                    D ]\  }\  }}}|rx||         }t          |t                    r|j        }|	                    ||||                   }t          |          }|||<   |                    d| d	| d
|dz
   d           |r|                    d|j         d	| d| d           d                    |          }t                              |           t          ||           t!          |d                   }t#          j        t#          j        |                    rt"          j        |d<   dg}t          |          D ]!\  }}|                    d| d| d           "d                    |          }t                              |           t          ||           t!          |d                   }t           d             }|||fS )Nc                <    g | ]\  }}}}t          ||||          S r:   )r{   )r4   combro   n_redcats        r6   r>   z4make_antialias_stage_2_functions.<locals>.<listcomp>   sE     R R RMcTSWY^`c0tUCHH R R Rr8   c                6    g | ]}|                                 S r:   is_wherer4   r<   s     r6   r>   z4make_antialias_stage_2_functions.<locals>.<listcomp>        111aQZZ\\111r8   r   Fr   c              3      K   | ]	}d | V  
dS )rk   Nr:   r4   is     r6   r7   z3make_antialias_stage_2_functions.<locals>.<genexpr>   s(      ,,q]q]],,,,,,r8   )z7def aa_stage_2_accumulate(aggs_and_copies, first_pass):z    if first_pass:z1        for a in literal_unroll(aggs_and_copies):z            a[1][:] = a[0][:]z	    else:z        z(aggs_and_copies[z][::-1], aggs_and_copies[z][::-1])z][1], aggs_and_copies[z][0])
aa_stage_2_accumulatenanz&def aa_stage_2_clear(aggs_and_copies):z    aggs_and_copies[z
][0].fill()aa_stage_2_clearc                `    t          |           D ]}|d         d d          |d         d d <   d S )Nr   r   r   )aggs_and_copiesagg_and_copys     r6   aa_stage_2_copy_backz>make_antialias_stage_2_functions.<locals>.aa_stage_2_copy_back  sG     +?;; 	4 	4L!-a!3LOAAA	4 	4r8   )rT   r   set__name__r   	enumerate
isinstancer   	reduction_combine_callbacknextrh   joinloggerdebugexecr   rR   anyisnanr   )r_   r]   r.   r/   aa_combinations	aa_zeroesaa_n_reductionsaa_categoricalfuncsbase_is_wherenext_base_is_where	namespacefuncnameslinesr   r   next_is_wherewhere_reductionrk   namecoder   aa_zeror   r   s                             r6   rS   rS      s'   BS?OYR ROYPPR R RE 215111M&qrr*eW4I"0IE

 ( (#'	$-   -,EGG,,,E  E /8E=<N9P 9P /Q /Q ^ ^**D(M 	^#AhO/2.. <"1";%77k>Z[K\]]G;;D%IdOLL[4[[![[aPQc[[[] ] ] ] 	^LL\4=\\1\\TU\\\^ ^ ^ ^99UD
LLy!),C"DEE 
vbhy!!"" "6	%56E	** E E
7CACCCCCDDDD99UD
LLyY'9:;; 4 4 U4
 !"24HHHr8   c              #     K   t          | t                    r"| j        D ]}t          |          D ]}|V  dS | V  dS )z/Yield a left->right traversal of an aggregationN)r   r   valuesrO   )rZ   aa2s      r6   rO   rO     si      #w  	 	A*1--  	 	 					r8   c           	        |                      |||||          | f| j        | j        |                     |          |                     ||          |r|                                 nt          j        |                                 fS r2   )	_build_appendinputsnan_check_column_build_temps_build_combine_tempsuses_cuda_mutexr   Nois_categorical)basedshaper=   r.   r-   rB   r/   s          r6   r@   r@     s     	664NKK	$!!$44"&<M,<	 	r8   c                f    d t          | |          D             |rdd l}|nt          fdS )Nc                >    g | ]\  }}|                     |          S r:   )_build_create)r4   r<   rA   s      r6   r>   zmake_create.<locals>.<listcomp>(  s(    EEEv1""EEEr8   r   c                >     t           fdD                       S )Nc              3  0   K   | ]} |          V  d S r2   r:   )r4   rH   r`   shapes     r6   r7   z0make_create.<locals>.<lambda>.<locals>.<genexpr>.  s/      HH!qq55HHHHHHr8   )tuple)r   r`   creatorss   `r6   <lambda>zmake_create.<locals>.<lambda>.  s(    HHHHHxHHHHH r8   )rT   rQ   rR   )r]   r^   r.   rQ   r`   r   s       @@r6   rU   rU   '  sP    EEUG1D1DEEEH HHHHHHr8   r   c                      fd}|S )Nc                .    t           fdD                       }	rtdd l}dd l}ddlm}  ||j                   |d          k    r"|                    |t          j                  }n!|                    dt          j                  }||fz  }|S )Nc              3  D   K   | ]}|                               V  d S r2   )apply)r4   rH   r.   dfs     r6   r7   z*make_info.<locals>.info.<locals>.<genexpr>3  s1      44!AGGB%%444444r8   r   )Versionz0.57)dtype)r   )	r   rQ   numbapackaging.versionr   __version__zerosrR   uint32)
r   canvas_shaperetrQ   r   r   mutex_arrayrc   r.   r   s
   `      r6   rj   zmake_info.<locals>.info2  s    44444t44444 	"KKKLLL111111wu())WWV__<<"jjRYjGG"jjRYj??K>!C
r8   r:   )rc   r.   r   rj   s   ``` r6   rW   rW   1  s/           Kr8   c                @  +,-. d t                      D             -t          |           t          |          z   }i }t          d |D                       }|r
t          |d<   t          d |D                       }t          d |D                       }	|	r|dgz  }t          |d<   t
          |d<   -fd	|D             }
t          t          ||
                    +i ,g }g }|j        }|-d
	                    d t          |          D                       .nd .d}i }i }t                              t          j                  rt                              d|            t                              d|	            +                                D ]7\  }}t                              d| d| dt#          |dd                       8d8+fd}t%          |          D ]\  }\  }} }}}}}}| o|t&          j        k    },                    t          |-fd|D                                  t-          -          }t                              d| d|            |||<   +fd| D             }|rFt/          |d         t0                    r+|                    +.fd|dd          D                        nk|"|                    +fd|D                        nG|r#|                    +.fd|D                        n"|                    +.fd|D                        |r+|d                  }|                    |d           }|Wt/          |d         t0                    rd nd!} d"t-          -           }|||<   |                    | d#| d$. d%|  d&           |
|         }!|                    |! d'|! d(| d%           |                    ,fd)|D                        |r|                    d*           |r|r|                                 t;          |           dk    o| d                                         }"|"rp| d         }#t/          |#t>                    r|#j         }#tC          |#j"                  }$|                    |$d           }%|%d u }&|&rt-          -          }%|%||$<   |                    |%           |                                }'|r |s|                     |d+                     |&r|                    |% d'|'            n|                    |'           |d }(n9+|          d$. d%})|d,         }'d-|) d.|d,<   |                    d/|'            d/}(|                    |( d0|% d1           |                    d/|( | d2d
	                    |           d&           n|r |s|                     |d+                     |rW+|          d$. d%})|                    d-|) d.           |                    d/| d2d
	                    |           d&           n.|                    | d2d
	                    |           d&           |r|                     |d                     |}|+fd3,                                D             z   |z   }|r |d+          g|z    |d          gz   }|r|
#                    dd*           |=d4$                    d
	                    |
          d5	                    |                    }*n=d6$                    .d
	                    |
          d5	                    |                    }*t                              |*           tK          |*|           tM          |d7                   |	fS )9Nc              3  @   K   | ]}d                      |          V  dS )z_{0}Nformatr   s     r6   r7   zmake_append.<locals>.<genexpr>C  s.      //!V]]1//////r8   c              3  &   K   | ]}|d          V  dS rE   r:   r4   calls     r6   r7   zmake_append.<locals>.<genexpr>F  s&      00$d1g000000r8   r   c              3  B   K   | ]}|d          t           j        k    V  dS    N)r   Globalr   s     r6   r7   zmake_append.<locals>.<genexpr>I  s.      NNDG}';;NNNNNNr8   c              3  B   K   | ]}|d          t           j        k    V  dS r   )r   r   r   s     r6   r7   zmake_append.<locals>.<genexpr>J  s.      LLdd1g)99LLLLLLr8   _cuda_mutexr)   r*   c                .    g | ]}t                    S r:   r   r4   r   r   s     r6   r>   zmake_append.<locals>.<listcomp>Q  s    ---e---r8   z, c                2    g | ]}d t          |          z   S )r   )str)r4   ns     r6   r>   zmake_append.<locals>.<listcomp>X  s"    BBBsSVV|BBBr8   Fzglobal_cuda_mutex zany_uses_cuda_mutex zarg_lk  rL   lockrr   returnr   c                ,    | rdnd}| dd          dS )Nr)   r*   (r   z	, (y, x))r:   )r   r   arg_lks     r6   get_cuda_mutex_callz(make_append.<locals>.get_cuda_mutex_calle  s0    $(A  .A99.9999r8   c              3  6   K   | ]}t                    V  d S r2   r   r   s     r6   r7   zmake_append.<locals>.<genexpr>l  s)      #?#?ADKK#?#?#?#?#?#?r8   zfunc c                     g | ]
}|         S r:   r:   r4   r   r   s     r6   r>   zmake_append.<locals>.<listcomp>p  s    )))aq	)))r8   r   c              3  P   K   | ] }d                      |                   V  !dS z{0}[{1}]Nr   )r4   colr   	subscripts     r6   r7   zmake_append.<locals>.<genexpr>r  s7      VVc
))&+yAAVVVVVVr8   r   c              3  N   K   | ]}d                      |                   V   dS )z{0}Nr   r   s     r6   r7   zmake_append.<locals>.<genexpr>t  s3      >>AVAY//>>>>>>r8   c              3  P   K   | ] }d                      |                   V  !dS )z{0}[{1}][1]Nr   r4   r   r   r   s     r6   r7   zmake_append.<locals>.<genexpr>v  sK       ' ' &,,VAY	BB ' ' ' ' ' 'r8   c              3  P   K   | ] }d                      |                   V  !dS r   r   r   s     r6   r7   zmake_append.<locals>.<genexpr>y  sK       ' ' #))&)Y?? ' ' ' ' ' 'r8    z[0]r   z = int([]r   z = z[:, :, c                     g | ]
}|         S r:   r:   )r4   r   local_lks     r6   r>   zmake_append.<locals>.<listcomp>  s    000QXa[000r8   	aa_factorTru   zif not isnull(z):z    zif z >= 0:z(x, y, c                N    g | ]!\  }}d                      ||                   "S )z{0} = {1}[y, x]r   )r4   rZ   r   r   s      r6   r>   zmake_append.<locals>.<listcomp>  sA     6 6 6 sD %++D&+>> 6 6 6r8   zdef append(x, y, {0}):
    {1}z
    z#def append({0}, x, y, {1}):
    {2}rh   )r   rr   r   r   )'r   rN   r   r   r)   r*   dictrT   ndimsr   ranger   isEnabledForloggingDEBUGr   itemsgetattrr   r   Localupdater   r   r   extendr	   rh   poplenr   r   r   hashselectorinsertr   r   r   )/r]   rc   rb   r[   r-   r   r   need_isnullglobal_cuda_mutexri   	signatureheadbodyr  prev_local_cuda_mutexcategorical_argswhere_selectorskvr   indexr   r   re   _r   rs   local_cuda_mutex	func_nameargscategorical_argcat_name	col_indexargr   r   selector_hashupdate_index_arg_namenew_selector	prev_body
whitespacevarr   r   r   r   r   s/                                              @@@@r6   rV   rV   B  s^	   //uww///E%[[4::%FI00%00000K %$	(NNNNNNNLLeLLLLL ; 	=/!'6	#$):	%&----f---I#fi(())FHDDKEIIBBU5\\BBBCC			!O7=)) I=*;==>>>A,?AABBBLLNN 	I 	IDAqLLG1GGqGG71h+E+EGGHHHH: : : : : :
 [1 [1\\eT#3UAP[00[_H[5[E#?#?#?#?#?#?#?@@AAAKK	/Y////000#	)))))5))) 		':d1g~>> 		'KKVVVVVTRSRTRTXVVVVVVV]KK>>>>>>>>>>> 	'KK ' ' ' ' '!%' ' ' ' ' ' ' KK ' ' ' ' '!%' ' ' ' ' '  	<$T!WoO'++OTBBH",T!Wn"E"EPBB5	.e..4< 1xZZZZ)ZZiZZZ[[[E"CKK3::3::x:::;;;0000%000111 	%KK$$$ 	 5 	HHJJJu::?:uQx'8'8':': -	E#AhO/2.. <"1"; !9::M$3$7$7t$L$L!0D8L G(,U%1F.KK-... 

I 7(= 7//55666 '4DDDDEEEEI&&&
  '

 01@@I@@@ H	3C333R.9..///#
KK:GG*?GGGHHHKKOzO9OOTYYt__OOOPPPP 7(= 7//55666 E 01@@I@@@4S444555G9GGTYYt__GGGHHHHyCC4CCCDDD 	4KK++E22333 0 6 6 6 6$,NN$4$46 6 6 68<=D  Q##D))*T15H5H5O5O4PP )K(((}!6$))I"6"6d8K8KLL 	&DIIi$8$8(--:M:MNN 	 LLy8$%%':::r8   c                T  	
 t          d t          |           D                       		                    t          d t          |           D                                  d | D             

dd          dgz   }	fdt          | ||||          D             
fd}|S )Nc              3  $   K   | ]\  }}||fV  d S r2   r:   r4   r  r  s      r6   r7   zmake_combine.<locals>.<genexpr>  *      88Va1a&888888r8   c              3  X   K   | ]%\  }}t          |t                    |j        |fV  &d S r2   )r   r   r   r-  s      r6   r7   zmake_combine.<locals>.<genexpr>  s>      \\FQ*UVXZJ[J[\Q'\\\\\\r8   c                6    g | ]}|                                 S r:   r   r   s     r6   r>   z make_combine.<locals>.<listcomp>  r   r8   r   Fc                ~    g | ]9\  }}}}}|rd n|                     |	          fd|f|z   |z   D             f:S )Nc                     g | ]
}|         S r:   r:   r   s     r6   r>   z+make_combine.<locals>.<listcomp>.<listcomp>  s    000Qvay000r8   )_build_combine)
r4   r<   rA   tctr   r-   r   r.   r/   s
         r6   r>   z make_combine.<locals>.<listcomp>  s|     d d d!!Q2q NddQ--aD+NN00001$(R-0002 d d dr8   c                0   t          d t          |  D                       }g }t                    D ]T\  }\  }}| |t          ||           }|r|                    |d d d                    ?|                    |           Ut          |          S )Nc              3  >   K   | ]}t          j        |          V  d S r2   )rR   stack)r4   bss     r6   r7   z0make_combine.<locals>.combine.<locals>.<genexpr>  s*      ??rbhrll??????r8   ru   )r   rT   r	   r  rh   )	base_tuplesr]   r   r   r   indsr   r   rb   s	          r6   rk   zmake_combine.<locals>.combine  s    ??S+->?????&)-&?&? 		! 		!"HltT|4T5))*D ! 

4":&&&&

4    Szzr8   )r  r   r  rT   )r]   r^   re   rf   r-   r.   r/   r   rk   r   r   rb   s       ```  @@@r6   rX   rX     s    88y'7'788888F
MM$\\i6F6F\\\\\]]] 215111M&qrr*eW4d d d d d d d%(Oa%b%bd d dE      Nr8   c                  
 t          d t          |           D                       
t          t                    rg t	          j        j                  D ]f\  }}t          | ||||          }	 |                    ||          } n# t          $ r Y nw xY w
fd| D             }
                    |||f           gdfd	}	|	S                     |          S )Nc              3  $   K   | ]\  }}||fV  d S r2   r:   r-  s      r6   r7   z make_finalize.<locals>.<genexpr>  r.  r8   c                     g | ]
}|         S r:   r:   )r4   r<   r   s     r6   r>   z!make_finalize.<locals>.<listcomp>  s    ---!F1I---r8   Fc                      fdD             j         d         fddD             }t          j        |          S )Nc           	     J    i | ]\  }}}| |t          |          fi  S r:   )r	   )r4   key	finalizerr;  r]   r.   kwargss       r6   
<dictcomp>z3make_finalize.<locals>.finalize.<locals>.<dictcomp>
  sO     9 9 9.i 3tU#3#3TDDVDD 9 9 9r8   r   c                8    i | ]}|         j         |         S r:   attrs)r4   attrdatar   s     r6   rD  z3make_finalize.<locals>.finalize.<locals>.<dictcomp>  s'    UUUdT4:+D1UUUr8   )x_rangey_rangerF  )keysxrDataset)r]   r.   rC  rG  rI  r   rZ   rb   s   ``` @@r6   rl   zmake_finalize.<locals>.finalize	  sy    9 9 9 9 9 9279 9 9D
 8A;DUUUUU>TUUUE:d%0000r8   )F)r  r   r   r   rT   rL  r   rY   r3   AttributeErrorrh   _build_finalize)r]   rZ   r=   r.   r/   rA  valfr;  rl   r   rb   s    `        @@r6   rY   rY     s$   88y'7'788888F#w +CHcj11 	) 	)HCeS&$DDA(({;;!   ----u---DLL#q$((((		1 		1 		1 		1 		1 		1 		1 ""6***s   4B
BBc                Z    d| D ]}|                                 rd ndfd}|fS )NTFr   r+   c                f     t          t          t           fdD                                  S )Nc              3  D   K   | ]}|                               V  d S r2   )_antialias_stage_2)r4   r<   r`   rB   s     r6   r7   zDmake_antialias_stage_2.<locals>.antialias_stage_2.<locals>.<genexpr>$  sG       !1 !1%& "#!5!5nl!S!S !1 !1 !1 !1 !1 !1r8   )r   rT   r   )r`   r]   rB   s   `r6   r_   z1make_antialias_stage_2.<locals>.antialias_stage_2#  sT    S& !1 !1 !1 !1 !1*/!1 !1 !1 1 1 2 3 3 	3r8   )r   r+   )_antialias_requires_2_stages)r\   r]   redr_   rB   s    `  @r6   rP   rP     sn    
 N  ++-- 	"NE	3 3 3 3 3 3 3 ,,,r8   )rn   r   ro   rp   rq   rr   rs   rr   )r   rr   )F
__future__r   	itertoolsr   r  typingr   toolzr   r   r   r	   r
   r   r   numpyrR   xarrayrM  r-   r   
reductionsr   r   r   r   r   utilsr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   )datashader.transfer_functions._cuda_utilsr)   r*   ImportErrordatashader.antialiasr+   __all__	getLoggerr   r   r,   r{   rS   rO   r@   rU   rW   rV   rX   rY   rP   r:   r8   r6   <module>rf     s-   " " " " " "                    5 5 5 5 5 5 5 5 5 5 5 5 5 5                     + + + + + + Q Q Q Q Q Q Q Q Q Q Q Q Q Q                                             4\\\\\\\\\ 4 4 4)3&O&&&4  =<<<<<<  
  
	8	$	$ 	8=EW\ q q q q 	qh*' *' *' *'ZFI FI FIR    I I I   "V; V; V;r  @+ + +:- - - - -s   6A? ?
BB