
    em                     V   d dl Zd dlmZ d dlZd dlZd dlZ	 d dl	m
Z n# e$ r dZY nw xY w	 d dlZn# e$ r dZY nw xY w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 d dlmZ d dlm Z  d dl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)  eedu d          Z* eedu d          Z+ G d	 d
e           Z,dS )    N)skipIf)AreaContoursCurveDataset	GridSpace	HistogramHoloMapImageNdLayout	NdOverlayPointsPolygonsQuadMeshrenderer)GridInterface)ComparisonTestCase)contoursdecimategradient	histograminterpolate_curve	operation	threshold	transformzdask.array is not availablezibis is not availablec                   |   e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zed             Zed             Z ed             Z!e"e#j$        %                    d          d                          Z&e"e#j$        %                    d          d!                         Z'e"e#j$        %                    d          d"                         Z(d# Z)d$ Z*d% Z+d& Z,d' Z-d( Z.d) Z/d* Z0d+ Z1d, Z2d- Z3d. Z4d/ Z5d0 Z6d1 Z7d2 Z8d3 Z9d4 Z:d5 Z;d6 Z<d7 Z=d8 Z>d9 Z?d:S );OperationTestszU
    Tests allowable data formats when constructing
    the basic Element types.
    c                     t          t          j                            dd                    }t	          |d           }|                     ||                    |j        dz  d                     d S )N
   c                 <    |                      | j        dz            S N   clonedataxks     Hlib/python3.11/site-packages/holoviews/tests/operation/test_operation.py<lambda>z7OperationTests.test_operation_element.<locals>.<lambda>;   s    q0A0A     opr"   	Operationgroup)r   nprandomrandr   assertEqualr$   r%   selfimgop_imgs      r)   test_operation_elementz%OperationTests.test_operation_element9   sg    BINN2r**++3#A#ABBB38A:[!I!IJJJJJr+   c                    t          d t          d          D                       }t          |d           }|                    d |                                D                       }|                     ||           d S )Nc           	      j    i | ]0}|t          t          j                            d d                     1S r   r   r1   r2   r3   .0is     r)   
<dictcomp>z:OperationTests.test_operation_ndlayout.<locals>.<dictcomp>?   s2    QQQ!QbinnR&<&< = =QQQr+   r   c                 <    |                      | j        dz            S r!   r#   r&   s     r)   r*   z8OperationTests.test_operation_ndlayout.<locals>.<lambda>@   s    !''!&(:K:K r+   r,   c                 T    i | ]%\  }}||                     |j        d z  d          &S r"   r.   r/   r#   r?   r(   vs      r)   rA   z:OperationTests.test_operation_ndlayout.<locals>.<dictcomp>A   sJ     "@ "@ "@&*a #$QWWQVAX[W%I%I "@ "@ "@r+   )r   ranger   r$   itemsr4   )r6   ndlayoutop_ndlayoutdoubleds       r)   test_operation_ndlayoutz&OperationTests.test_operation_ndlayout>   s    QQuRyyQQQRR-K-KLLL.. "@ "@.6nn.>.>"@ "@ "@ A Ag.....r+   c                 
   t          d t          d          D             dg          }t          |d           }|                    d |                                D                       }|                     ||           d S )Nc           	      j    i | ]0}|t          t          j                            d d                     1S r<   r=   r>   s     r)   rA   z6OperationTests.test_operation_grid.<locals>.<dictcomp>F   s2    NNNq!U29>>"b#9#9::NNNr+   r   X)kdimsc                 <    |                      | j        dz            S r!   r#   r&   s     r)   r*   z4OperationTests.test_operation_grid.<locals>.<lambda>G       !''!&(2C2C r+   r,   c                 T    i | ]%\  }}||                     |j        d z  d          &S rD   r#   rE   s      r)   rA   z6OperationTests.test_operation_grid.<locals>.<dictcomp>H   sD     8 8 8"&!Q  !E!E 8 8 8r+   )r   rG   r   r$   rH   r4   )r6   gridop_gridrK   s       r)   test_operation_gridz"OperationTests.test_operation_gridE   s    NNE"IINNNWZV[\\\D%C%CDDD** 8 8*.**,,8 8 8 9 9'*****r+   c           	      &   t          dt          t          j                            dd                    i          }t          |d           }|                     |j        |j                            |j        j	        dz  d                     d S )N   r   c                 <    |                      | j        dz            S r!   r#   r&   s     r)   r*   z7OperationTests.test_operation_holomap.<locals>.<lambda>N   rR   r+   r,   r"   r.   r/   )
r
   r   r1   r2   r3   r   r4   lastr$   r%   )r6   hmapop_hmaps      r)   test_operation_holomapz%OperationTests.test_operation_holomapL   s{    5B!7!7889::D%C%CDDDtyty~a7G{'['[\\\\\r+   c                     t          t          j                            dd                    }t	          |d           }|                     ||                    |j        dz  d                     d S )Nr   c                     | dz  S r!    r'   s    r)   r*   z5OperationTests.test_image_transform.<locals>.<lambda>S   s
    1Q3 r+   )operatorr"   	Transformr/   )r   r1   r2   r3   r   r4   r$   r%   r5   s      r)   test_image_transformz#OperationTests.test_image_transformQ   se    BINN2r**++377738A:[!I!IJJJJJr+   c           
          t          t          j        g dg dg                    }t          |          }|                     ||                    t          j        g dg dg          d                     d S )Nr   rX   r         g      @)rX   rX   rX   	Thresholdr/   )r   r1   arrayr   r4   r$   r5   s      r)   test_image_thresholdz#OperationTests.test_image_thresholdV   su    BHiii45566328YYY			4J+K+KS^!_!_`````r+   c           
          t          t          j        g dg dg dg                    }t          |          }|                     ||                    t          j        ddgddgg          d                     d S )Nrf   rg            gvhXL	@Gradientr/   )r   r1   rk   r   r4   r$   r5   s      r)   test_image_gradientz"OperationTests.test_image_gradient[   s~    BHiiiYYY?@@AA#28h5IHV^K_4`+a+ais!t!tuuuuur+   c                 
   t          t          j        g dg dg                    }t          |dg          }t	          ddt          j        t          j        dfddgg|j                  }|                     ||           d S )	Nrf         ?levels)gtE)!XUſ      ?ru   )gUUſ      пru   )UU?ry   ru   )rz   rx   ru   vdims)r   r1   rk   r   r   nanr|   r4   r6   r7   op_contourscontours       r)   test_image_contoursz"OperationTests.test_image_contours`   s    BHiii34455sC511135M fbfc24K35 6 #&)- - - 	g.....r+   c                     t          t          j        g dg dg                    }t          |dg          }t	          g |j                  }|                     ||           d S )Nrf         7@rv   r{   )r   r1   rk   r   r   r|   r4   r~   s       r)   test_image_contours_emptyz(OperationTests.test_image_contours_emptyj   sj    BHiii34455sD62222SY///g.....r+   c                    t          j        g dg dg dg          }t          |          }t          dd          D ]}t	          ||          }d |j        D             }t          |          |dz   k    sJ t          j        |          |                                k    sJ t          j        |          |                                k     sJ d S )	Nrf   rg   rn   rh      rv   c                     g | ]
}|d          S zr`   r?   items     r)   
<listcomp>zBOperationTests.test_image_contours_auto_levels.<locals>.<listcomp>v       ===Dd3i===r+   r"   	r1   rk   r   rG   r   r%   lenminmax)r6   r   r7   nlevelsr   rw   s         r)   test_image_contours_auto_levelsz.OperationTests.test_image_contours_auto_levelsq   s    HiiiYYY788AhhQ|| 	, 	,G"3w777K==K,<===Fv;;'A+----6&>>QUUWW,,,,6&>>AEEGG+++++	, 	,r+   c                     t          t          j        d                    }t          |d          }t	          g |j                  }|                     ||           d S )N)r"   r"   r"   rv   r{   )r   r1   zerosr   r   r|   r4   r~   s       r)   test_image_contours_no_rangez+OperationTests.test_image_contours_no_range{   s[    BHV$$%%s1---2SY///g.....r+   c                 l   t          j        g dd          }ddg}t          j        g dg dg          }t          |||f          }t          |dg          }t          j        j        }t          j        t	          j        d	d
d|          t	          j        d	d
d|          t           j        t	          j        d	d
d|          t	          j        d	d
d|          gt                    }|
                    d          }t          j        g d          }t           j                            ||         ||                    t           j                            ||                              t                    ||                              t                               t           j                            |
                    d                              t                    ddt           j        ddg           t           j                            |
                    d          dgdz             d S )N
2023-09-01
2023-09-03
2023-09-05
datetime64dtype      rf   ru   rv     	   r"   tzinfori   r'   TTFTTyr      r1   rk   r   r   dttimezoneutcdatetimer}   objectdimension_valuestestingassert_array_equalastypefloatassert_array_almost_equal)	r6   r'   r   r   r7   r   tz
expected_xmasks	            r)   test_image_contours_x_datetimez-OperationTests.test_image_contours_x_datetime   s   H???|TTTHHiii+,,Q1IsC5111[_X[q!B///T1aPR1S1S1SUWU[[q!B///T1aPR1S1S1SU  
 ((--x77788

%%agz$/?@@@

%%ahooe&<&<j$>O>V>VW\>]>]^^^

,,[-I-I#-N-N-U-UV[-\-\.0"bfb"-E	G 	G 	G

,,[-I-I#-N-NQTPUVWPWXXXXXr+   c                 l   g d}t          j        ddgd          }t          j        g dg dg          }t          |||f          }t          |dg          }t           j                            |                    d	                              t                    d
d
t           j	        ddg           t          j        j        }t          j        t          j        ddd|          t          j        ddd|          t           j	        t          j        ddd|          t          j        ddd|          gt                    }|                    d          }t          j        g d          }t           j                            ||         ||                    t           j                            ||                              t                    ||                              t                               t           j                            |                    d          dgdz             d S )N)r   r      r   r   r   r   rf   ru   rv   r'   g      -@g      /@r   r   rh   r   rX   r   r   r   r   )r1   rk   r   r   r   r   r   r   r   r}   r   r   r   r   r   r   )	r6   r'   r   r   r7   r   r   
expected_yr   s	            r)   test_image_contours_y_datetimez-OperationTests.test_image_contours_y_datetime   s   LLHlL1FFFHiii+,,Q1IsC5111

,,[-I-I#-N-N-U-UV[-\-\.2D"&$-M	O 	O 	O [_X[q!B///T1aPR1S1S1SUWU[[q!B///T1aPR1S1S1SU  
 ((--x77788

%%agz$/?@@@

%%ahooe&<&<j$>O>V>VW\>]>]^^^

,,[-I-I#-N-NQTPUVWPWXXXXXr+   c                 "   t          j        g dd          }t          j        ddgd          }t          j        g dg dg          }t          |||f          }t          |dg          }t          j        j        }t          j        t	          j        d	d
d|          t	          j        d	d
d|          t           j        t	          j        d	d
d|          t	          j        d	d
d|          gt                    }t          j        t	          j        d	dd|          t	          j        d	dd|          t           j        t	          j        d	dd|          t	          j        d	dd|          gt                    }|
                    d          }t          j        g d          }	t           j                            ||	         ||	                    t           j                            ||	                              t                    ||	                              t                               |
                    d          }t           j                            ||	         ||	                    t           j                            ||	                              t                    ||	                              t                               t           j                            |
                    d          dgdz             d S )Nr   r   r   z
2023-10-07z
2023-10-08rf   ru   rv   r   r   r"   r   ri   r   rq   rp   r'   r   r   r   r   r   )
r6   r'   r   r   r7   r   r   r   r   r   s
             r)   test_image_contours_xy_datetimez.OperationTests.test_image_contours_xy_datetime   s   H???|TTTHlL1FFFHiii+,,Q1IsC5111 [_X[q!B///T1aPR1S1S1SUWU[[q!B///T1aPR1S1S1SU  
 X[r1R000"+dBRT2U2U2UWYW][r1R000"+dBRT2U2U2UW  
 ((--x77788

%%agz$/?@@@

%%ahooe&<&<j$>O>V>VW\>]>]^^^((--

%%agz$/?@@@

%%ahooe&<&<j$>O>V>VW\>]>]^^^

,,[-I-I#-N-NQTPUVWPWXXXXXr+   c                    t          j        ddgddggd          }t          |          }t          |t          j        d          g          }t           j                            |                    d          dd	g           t           j                            |                    d
          d	dg           t          j        t          j	        dddddt          j
        j                  t          j	        dddddt          j
        j                  gt                    }t           j                            |                    d          |           d S )Nz
2023-09-10z
2023-09-12r   r   z
2023-09-11rv   r'   rx           r   ry   r   r      r   r   r   )r1   rk   r   r   r   r   r   r   r   r   r   r   r   r   )r6   r   r7   r   
expected_zs        r)   test_image_contours_z_datetimez-OperationTests.test_image_contours_z_datetime   s6   H|\2\<4PQYefffAhhsBM,,G,G+HIII

,,[-I-I#-N-NQUWZP[\\\

,,[-I-I#-N-NQTV[P\]]]XKaQ"+/BBBKaQ"+/BBBDKQS S S
 	
%%k&B&B3&G&GTTTTTr+   c           
         t          g dg dt          j        g dg dg dg          f          }t          |dg          }t	          dd	t          j        t          j        dfd
dgg|j                  }|                     ||           d S )Nr   rX   r"   rX   r"   rh   rf   rg   rn   ru   rv   )r   g(%?ru   )ru         ?ru   )      ?r   ru   )r"   g?ru   r{   )r   r1   rk   r   r   r}   r|   r4   )r6   qmeshr   r   s       r)   test_qmesh_contoursz"OperationTests.test_qmesh_contours   s    )))YYY)))ZZZQZQZQZ9[0\0\]^^ucU3330. fbfc2N*, - #(+/ / / 	g.....r+   c                 |   t          j        d          x}}t          j        ||          \  }}t          j        g dg dg dg          }t	          ||dz   |f          }t          |dg          }t          dd	t           j        t           j        dfd
dgg|j                  }| 	                    ||           d S )Nrh   rf   rg   rn   皙?ru   rv   r   g 	v?ru   ru   r   ru   r   r   ru   r"   皙?ru   r{   )
r1   arangemeshgridrk   r   r   r   r}   r|   r4   	r6   r'   r   xsyszsr   r   r   s	            r)   test_qmesh_curvilinear_contoursz.OperationTests.test_qmesh_curvilinear_contours   s    	!AQ""BXyyy***iii899"bfb)**ucU3330/ fbfc2O*, - #(+/ / / 	g.....r+   c                     t          j        d          x}}t          j        ||          \  }}t          j        |          }t          j        |d          }t          j        |          }t          j        |d          }t          j        g dg dg dg          }t          ||dz   |f          }t          |dg          }t          d	d
t           j	        t           j	        dfddgg|j
                  }|                     ||           d S )Nrh   rX   rf   rg   rn   r   ru   rv   r   r   r   r   r{   )r1   r   r   r   _infer_interval_breaksrk   r   r   r   r}   r|   r4   r   s	            r)   %test_qmesh_curvilinear_edges_contoursz4OperationTests.test_qmesh_curvilinear_edges_contours   s   	!AQ""B1"551"a881"551"a88Xyyy***iii899"bfb)**ucU3330/ fbfc2O*, - #(+/ / / 	g.....r+   c                 R   t          t          j        g dg dg                    }t          |dddg          }dddd	dt          j        t          j        d
fdddddgg}t          ||j        d                             d                    }|                     ||           d S )Nr   r"   r   Tru   r   filledrw   )ry   ry   rX   )iKGUUry   rX   )r   rx   rX   )ry   rx   rX   rX   )iKGUU?ry   rX   )rx   ry   rX   )rx   rx   rX   )r   rx   rX   r   )ru   r   rG   r{   )	r   r1   rk   r   r}   r   r|   r$   r4   )r6   r7   r   r%   polyss        r)   test_image_contours_filledz)OperationTests.test_image_contours_filled   s    BHiii34455s4c
CCC"$;=S!#4rvrvq6IKa!?4IKac d SYq\%7%7j%7%I%IJJJe,,,,,r+   c                    t          t          j        g dg dg dg                    }t          |dddg          }g dg}t	          ||j        d                             d	
                    }|                     ||           t          j        ddgddgddgddgddgg          ggg}t          j        	                    |
                                |           d S )Nr   r   r   )r   rX   r   Trx         ?r   )ry   r   ru   )r   ry   ru   )rx   r   ru   )r   rx   ru   r   r   )rx   r   r   r{   r   r   r   r   r1   rk   r   r   r|   r$   r4   r   r   holesr6   r7   r   r%   r   expected_holess         r)   $test_image_contours_filled_with_holez3OperationTests.test_image_contours_filled_with_hole  s   BHiiiYYY?@@AAs4tEEE% % % &SYq\%7%7l%7%K%KLLLe,,,HsK&8;:LsU_N`'13&7#{9K&M N N O P Q

,,[->->-@-@.QQQQQr+   c           	         t          t          j        g dg dg dg                    }t          |dddg          }g dg}t	          ||j        d                             d	
                    }|                     ||           t          j        ddgddgddgddgddgg          t          j        ddgddgddgddgddgg          ggg}t          j        	                    |
                                |           d S )N)r   r   r   r   r   )r   rX   r   rX   r   T      ru   r   )皙ٿ燼1UUտr   )皙ɿr   r   )r   r   r   )r   r   r   )皙?r   r   )r   r   r   )r   燼1UU?r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   r   r   )r   ru   r   r{   r   gK}\UUſg333333ӿgK}\UU?gr   r   333333?r   r   s         r)   &test_image_contours_filled_multi_holesz5OperationTests.test_image_contours_filled_multi_holes  sJ   BHoooPQQRRs4sDDD6 6 6 7 SYq\%7%7k%7%J%JKKKe,,,Ht[&9D!9tZFX[_abZc'+[&9&; < <HsK&83(S*DUX[]^W_'*K&8&: ; ;< = > 	
,,[->->-@-@.QQQQQr+   c                    t          t          j        g dg dg dg                    }t          |dddg          }t	          g |j        d                             d	
                    }|                     ||           d S )Nrf   rg   rn   T      4@r   r   r   )r   r   r   r{   )r   r1   rk   r   r   r|   r$   r4   )r6   r7   r   r   s       r)    test_image_contours_filled_emptyz/OperationTests.test_image_contours_filled_empty$  s    BHiiiYYY?@@AAs4tEEE39Q<#5#5L#5#I#IJJJe,,,,,r+   c                    t          j        g dg dg dg          }t          |          }t          dd          D ]}t	          |d|          }d |j        D             }t          |          |d	z   k    sJ d
|d	         |d         z
  z  }t          j        |          |                                |z   k    sJ t          j        |          |                                |z
  k    sJ d S )Nrf   )rh   ri   r   rn   rh   r   Tr   c                     g | ]
}|d          S r   r`   r   s     r)   r   zIOperationTests.test_image_contours_filled_auto_levels.<locals>.<listcomp>0  r   r+   rX   ru   r   r   )r6   r   r7   r   r   rw   deltas          r)   &test_image_contours_filled_auto_levelsz5OperationTests.test_image_contours_filled_auto_levels+  s    HiiiIII677AhhQ|| 	5 	5G"3tGDDDK==K,<===Fv;;'A+----VAY./E6&>>QUUWWu_44446&>>QUUWWu_44444	5 	5r+   c                 N   t          j        g dd          }t          j        ddg          }t          j        g dg dg          }t          |||f          }d}t          j        t
          |          5  t          |d	d
dg          }d d d            d S # 1 swxY w Y   d S )N)r   r   z
2023-09-09r   r   ro   rp   r   zODatetime spatial coordinates are not supported for filled contour calculations.)matchTru   r   r   )r1   rk   r   pytestraisesRuntimeErrorr   )r6   r'   r   r   r7   msg_s          r)   %test_image_contours_filled_x_datetimez4OperationTests.test_image_contours_filled_x_datetime6  s    H???|TTTHaVHiii+,,Q1I`]<s333 	> 	>T3*===A	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   8BB!Bc                     t          d t          d          D                       }t          |dd          }t          g dg dfd	          }|                     ||           d S )
Nc                 ,    g | ]}t          |          S r`   r   r>   s     r)   r   z8OperationTests.test_points_histogram.<locals>.<listcomp>@      555aq555r+   r   rh   Tnum_binsnormedr   rh   ro   r   r   r   g =E?x_frequency	Frequencyr{   r   rG   r   r	   r4   r6   pointsop_histhists       r)   test_points_histogramz$OperationTests.test_points_histogram?  s}    5559955566FQt<<<,,,(<(<(<=;= = =$'''''r+   c                     t          t          j        t          j        gdg          }t          |g d          }t	          g dddgfd          }|                     ||           d S )Nr'   r   )binsr   x_countCountr{   )r   r1   r}   r   r	   r4   )r6   dsr  r  s       r)   *test_dataset_histogram_empty_explicit_binsz9OperationTests.test_dataset_histogram_empty_explicit_binsG  sn    bfbf%u--BYYY///)))aV,4HIII$'''''r+   c           	      h   dd l m} t           |j        t	          j        t          d          d          d          fdgdg	          }t          |dd
          }t          g dg dfd          }|                     |j	        d         |j
                   |                     ||           d S )Nr   r   fr   rh   chunksr'   daskdatatypeTr
  r  r  r  r{   r  
dask.arrayrk   r   
from_arrayr1   rG   r   r	   assertIsInstancer%   Arrayr4   r6   dar  r  r  s        r)   test_dataset_histogram_daskz*OperationTests.test_dataset_histogram_daskN  s    mbmBHU2YYc$B$B$BAOOOQUfX/ / /B4888,,,(<(<(<=;= = =gl=928DDD$'''''r+   c           	      j   dd l m} t           |j        t	          j        t          d          d          d          fdgdg	          }t          |dd
d
          }t          g dg dfd          }|                     |j	        d         |j
                   |                     ||           d S )Nr   r   r   r   rh   r!  r'   r#  r$  Tr  
cumulativer  r  r   g333333?rX   r  r{   r  r&  r+  s        r)   &test_dataset_cumulative_histogram_daskz5OperationTests.test_dataset_cumulative_histogram_daskZ  s    mbmBHU2YYc$B$B$BAOOOQUfX/ / /BtDIII,,,6;= = =gl=928DDD$'''''r+   c           	         dd l m} t           |j        t	          j        t          d          d          d           |j        d t          d          D             d          fdd	gd
g          }t          |d	dd          }t          g dg dfd	          }|                     |j	        d	         |j
                   |                     ||           d S )Nr   r   r   r   rh   r!  c                     g | ]}|d z  S )g      $@r`   r>   s     r)   r   zGOperationTests.test_dataset_weighted_histogram_dask.<locals>.<listcomp>j  s    $>$>$>qQsU$>$>$>r+   r'   r   r#  r$  T)weight_dimensionr  r  r  g-]?gam?g9?q?r{   r&  r+  s        r)   $test_dataset_weighted_histogram_daskz3OperationTests.test_dataset_weighted_histogram_daskf  s   mbmBHU2YYc$B$B$B1MMM#bm$>$>E"II$>$>$>qIIIK3Z6(4 4 4 BqNNN,,,(F(F(FG"$ $ $gl3/:::$'''''r+   ibis_sqlite_backendc                 <   t          j        t          t          j        d                              }t          j        |d          }t          |d          }t          |ddd	          }t          g d
g dfd          }| 
                    ||           d S )Nr   ra   tnamer'   r{   rh   T)	dimensionr  r  r  r  r  pd	DataFramedictr1   r   ibismemtabler   r   r	   r4   r6   dfr:  r  r  r  s         r)   test_dataset_histogram_ibisz*OperationTests.test_dataset_histogram_ibiss  s     \$2///00M"3'''Qc"""B#$GGG,,,(<(<(<=;= = =$'''''r+   c                 <   t          j        t          t          j        d                              }t          j        |d          }t          |d          }t          |ddd	          }t          g d
g dfd          }| 
                    ||           d S )Nr   ra   r:  r;  r'   r{   rh   Tr/  r  r1  r  r>  rD  s         r)   &test_dataset_cumulative_histogram_ibisz5OperationTests.test_dataset_cumulative_histogram_ibis  s     \$2///00M"3'''Qc"""BtDIII,,,6;= = =$'''''r+   c                 >   t          j        t          t          j        d                              }t          j        |d          }t          |d          }t          |g dd	          }t          g dd
dgfd          }| 
                    ||           d S )Nr   ra   r:  r;  r'   r{   r   rX   rh   Fr  r  rX   rh   r  r>  rD  s         r)   )test_dataset_histogram_explicit_bins_ibisz8OperationTests.test_dataset_histogram_explicit_bins_ibis  s     \$2///00M"3'''Qc"""BYYYu===)))aV,35 5 5$'''''r+   c                     t          d t          d          D                       }t          |ddd          }t          g dg dfd	
          }|                     ||           d S )Nc                 ,    g | ]}t          |          S r`   r  r>   s     r)   r   zBOperationTests.test_points_histogram_bin_range.<locals>.<listcomp>  r	  r+   r   rh   )r   rh   T)r  	bin_ranger  )rx   rx   ru   )r   r   g       @g      @r  r{   r  r  s       r)   test_points_histogram_bin_rangez.OperationTests.test_points_histogram_bin_range  s    5559955566FQ&NNN+++-=-=-=>;= = =$'''''r+   c                     t          d t          d          D                       }t          |g dd          }t          g dddgfd	          }|                     ||           d S )
Nc                 ,    g | ]}t          |          S r`   r  r>   s     r)   r   zFOperationTests.test_points_histogram_explicit_bins.<locals>.<listcomp>  r	  r+   r   rJ  FrK  rX   rh   r  r{   r  r  s       r)   #test_points_histogram_explicit_binsz2OperationTests.test_points_histogram_explicit_bins  s~    5559955566F5AAA)))aV,35 5 5$'''''r+   c                     t          j        d          }t          |          }t          |ddd          }t	          g dg dfd	          }|                     ||           d S )
Nri   Trh   F)r0  r  r  r   rX   r"   rh   )rX   r"   ri   r  r{   )r1   r   r   r   r	   r4   )r6   arrr  r  r  s        r)    test_points_histogram_cumulativez/OperationTests.test_points_histogram_cumulative  sr    illFtaNNN,,,			235 5 5$'''''r+   c                     t          d t          d          D                       }t          |dd          }t          g dg dfd	          }|                     ||           d S )
Nc                 ,    g | ]}t          |          S r`   r  r>   s     r)   r   zCOperationTests.test_points_histogram_not_normed.<locals>.<listcomp>  r	  r+   r   rh   Fr
  r  )rh   rh   ri   r  r{   r  r  s       r)    test_points_histogram_not_normedz/OperationTests.test_points_histogram_not_normed  sz    5559955566FQu===,,,			235 5 5$'''''r+   c                 L   t          j        d t          dd          D                       }t          t	          |d          dd          }t          j        g dd	
          t          j        g d          d}t          |dd          }|                     ||           d S )Nc                 :    g | ]}t          j        d d|          S i  rX   r   r   r>   s     r)   r   zDOperationTests.test_histogram_operation_datetime.<locals>.<listcomp>  &    GGGa"+dAq11GGGr+   rX   r   Dateri   Tr
  z2017-01-01T00:00:00.000000z2017-01-01T18:00:00.000000z2017-01-02T12:00:00.000000z2017-01-03T06:00:00.000000z2017-01-04T00:00:00.000000datetime64[us]r   QDjQ<rd  rd  rd  r`  Date_frequencyrf  r  rP   r|   )r1   rk   rG   r   r   r	   r4   r6   datesr  	hist_datar  s        r)   !test_histogram_operation_datetimez0OperationTests.test_histogram_operation_datetime  s    GG5A;;GGGHHGE622QtLLLH . . . 6FG G G !h (  (  (  ! !
 
	 &8WXXX$'''''r+   c                 r   t          j        d t          dd          D                                           d          }t	          t          |d          dd          }t          j        g d	d
          t          j        g d          d}t          |dd          }|                     ||           d S )Nc                 :    g | ]}t          j        d d|          S r]  r^  r>   s     r)   r   zFOperationTests.test_histogram_operation_datetime64.<locals>.<listcomp>  r_  r+   rX   r   Mr`  ri   Tr
  ra  rb  r   rc  re  rg  rh  )r1   rk   rG   r   r   r   r	   r4   ri  s        r)   #test_histogram_operation_datetime64z2OperationTests.test_histogram_operation_datetime64  s    GG5A;;GGGHHOOPSTTGE622QtLLLH . . . 6FG G G !h (  (  (  ! !
 
	 &8WXXX$'''''r+   c                 H   t          j        ddd                              d          }t          t	          |d          dd          }t          j        g d	d
          t          j        g d          d}t          |dd          }|                     ||           d S )Nz
2017-01-01z
2017-01-04D)freqr`  ri   Tr
  ra  rb  r   rc  re  rg  rh  )	r?  
date_range	to_periodr   r   r1   rk   r	   r4   ri  s        r)   "test_histogram_operation_pd_periodz1OperationTests.test_histogram_operation_pd_period  s    lLsCCCMMcRRGE622QtLLLH . . . 6FG G G !h (  (  (  ! !
 
	 &8WXXX$'''''r+   c                     t          t          j        g d                    }ddddd}t          j        t
                    5  t          |fi | d d d            d S # 1 swxY w Y   d S )N)ABC)rx  rz  Frh   )rO  r  r0  r  )r   r?  Seriesr   r  
ValueErrorr   )r6   serieskwargss      r)   test_histogram_categoricalz)OperationTests.test_histogram_categorical  s    ???3344)U%]^__]:&& 	( 	(f'''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   AA#&A#c                     t          d t          d          D                       }t          |ddd          }t          g dg dfdg	          }|                     ||           d S )
Nc                 ,    g | ]}t          |          S r`   r  r>   s     r)   r   zAOperationTests.test_points_histogram_weighted.<locals>.<listcomp>  r	  r+   r   rh   r   T)r  r5  r  r6  r  r{   r  r  s       r)   test_points_histogram_weightedz-OperationTests.test_points_histogram_weighted  s{    5559955566FQTRRR888,,,GPSuUUU$'''''r+   c                     t          d t          d          D                       }t          |dddd          }t          g dg dfdg	          }|                     ||           d S )
Nc                 ,    g | ]}t          |          S r`   r  r>   s     r)   r   zFOperationTests.test_points_histogram_mean_weighted.<locals>.<listcomp>  r	  r+   r   rh   r   T)r  r5  mean_weightedr  )r   g      @g      @r  r{   r  r  s       r)   #test_points_histogram_mean_weightedz2OperationTests.test_points_histogram_mean_weighted  s    5559955566FQ*.t= = =...,,,7uEEE$'''''r+   c                     t          t          g d          d          }t          g d          }|                     ||           d S )Nr   ru   rX   	steps-preinterpolation)r   r   )r   ru   rX   ru   )rX   rX   r"   rX   r   r   r4   r6   interpolatedcurves      r)   test_interpolate_curve_prez)OperationTests.test_interpolate_curve_pre  sP    ({{{););;WWWBBBCCu-----r+   c                     t          t          g dddg          d          }t          g dddg          }|                     ||           d S )Nr   r   rx  rX   ru   ry  r"   rX   rz  r   r   r{   r  r  )r  )r   ru   ry  r  )rX   rX   rz  r  r  r  s      r)   &test_interpolate_curve_pre_with_valuesz5OperationTests.test_interpolate_curve_pre_with_values  su    (/X/X/Xadfi`j)k)k)k7BD D D[[[dgilcmnnnu-----r+   c                 N   t          j        d t          dd          D                                           d          }g d}t	          t          ||f          d          }t          j        g dd	
          }t          |g df          }|                     ||           d S )Nc                 :    g | ]}t          j        d d|          S r]  r^  r>   s     r)   r   zFOperationTests.test_interpolate_datetime_curve_pre.<locals>.<listcomp>  r_  r+   rX   r   ro  rU  r  r  )2017-01-01T00:00:00r  2017-01-02T00:00:00r  2017-01-03T00:00:00r  2017-01-04T00:00:00datetime64[ns]r   )r   rX   rX   r"   r"   rh   rh   r1   rk   rG   r   r   r   r4   r6   rj  valuesr  dates_interpr  s         r)   #test_interpolate_datetime_curve_prez2OperationTests.test_interpolate_datetime_curve_pre  s    GG5A;;GGGHHOOPSTT(v)?)?{[[[x !
 !
 !

 "# # # |%:%:%:;<<u-----r+   c                     t          t          g d          d          }t          g d          }|                     ||           d S )Nr  	steps-midr  )r  )ru   r   )ru   ru   )r   ru   )r   rX   r  r  r  s      r)   test_interpolate_curve_midz)OperationTests.test_interpolate_curve_mid  sP    ({{{););;WWWRRRSSu-----r+   c                     t          t          g dddg          d          }t          g dddg          }|                     ||           d S )Nr  r   r   r{   r  r  )r  )ru   r   rx  )ru   ru   ry  )r   ru   ry  )r   rX   rz  r  r  r  s      r)   &test_interpolate_curve_mid_with_valuesz5OperationTests.test_interpolate_curve_mid_with_values  s    (/X/X/Xadfi`j)k)k)k7BD D D D D D #J( ( ( 	u-----r+   c                 N   t          j        d t          dd          D                                           d          }g d}t	          t          ||f          d          }t          j        g dd	
          }t          |g df          }|                     ||           d S )Nc                 :    g | ]}t          j        d d|          S r]  r^  r>   s     r)   r   zFOperationTests.test_interpolate_datetime_curve_mid.<locals>.<listcomp>  r_  r+   rX   r   ro  rU  r  r  )r  2017-01-01T12:00:00r  2017-01-02T12:00:00r  2017-01-03T12:00:00r  r  r  r   )r   r   rX   rX   r"   r"   rh   rh   r  r  s         r)   #test_interpolate_datetime_curve_midz2OperationTests.test_interpolate_datetime_curve_mid  s    GG5A;;GGGHHOOPSTT(v)?)?{[[[x !
 !
 !

 "# # # |%=%=%=>??u-----r+   c                     t          t          g d          d          }t          g d          }|                     ||           d S )Nr  
steps-postr  )r  )rX   r   r  )r"   ru   r  r  r  s      r)   test_interpolate_curve_postz*OperationTests.test_interpolate_curve_post+  sP    ({{{););<XXXBBBCCu-----r+   c                     t          t          g dddg          d          }t          g dddg          }|                     ||           d S )Nr  r   r   r{   r  r  )r  )rX   r   rx  r  )r"   ru   ry  r  r  r  s      r)   'test_interpolate_curve_post_with_valuesz6OperationTests.test_interpolate_curve_post_with_values0  s    (/X/X/Xadfi`j)k)k)k7CE E E 3 3 3 #J( ( ( 	u-----r+   c                 N   t          j        d t          dd          D                                           d          }g d}t	          t          ||f          d          }t          j        g dd	
          }t          |g df          }|                     ||           d S )Nc                 :    g | ]}t          j        d d|          S r]  r^  r>   s     r)   r   zGOperationTests.test_interpolate_datetime_curve_post.<locals>.<listcomp>9  r_  r+   rX   r   ro  rU  r  r  )r  r  r  r  r  r  r  r  r   )r   r   rX   rX   r"   r"   rh   r  r  s         r)   $test_interpolate_datetime_curve_postz3OperationTests.test_interpolate_datetime_curve_post8  s    GG5A;;GGGHHOOPSTT(v)?)?|\\\x !
 !
 !

 "# # # |%:%:%:;<<u-----r+   c                    t          g d          t          g d          z  }t          j        |          }t          g dg dg dfddg          }t          g dg dg dfddg          }|                     |||z             d S )Nr   r   r   r   Baseliner{   r"   ri   ro   )r   stackr4   r6   areasstackedarea1area2s        r)   test_stack_area_overlayz&OperationTests.test_stack_area_overlayE  s    YYY$yyy//1*U##iiiIII6sJ>OPPPiiiIII6sJ>OPPP%%-00000r+   c                 V   t          dt          g d          fdt          g d          fg          }t          j        |          }t          g dg dg dfddg          }t          g dg d	g dfddg          }|                     |t          d|fd|fg                     d S )
Nr   r   rX   r   r   r   r  r{   r  )r   r   r  r4   r  s        r)   test_stack_area_ndoverlayz(OperationTests.test_stack_area_ndoverlayL  s    AtIII/!T)))__1EFGG*U##iiiIII6sJ>OPPPiiiIII6sJ>OPPP)aZ!U,D"E"EFFFFFr+   c                 4   t           j        }t           j        }d gt           _        d gt           _        t          g d          }|                     t          |          j        t          |j                             |t           _        |t           _        d S )Nc                 .    dt          |j                  iS )Nlabel)strid)r-   r'   s     r)   r*   z?OperationTests.test_pre_and_postprocess_hooks.<locals>.<lambda>V  s    gs14yy5I r+   c                      |j         di |S )Nr`   )r$   )r-   r'   r~  s      r)   r*   z?OperationTests.test_pre_and_postprocess_hooks.<locals>.<lambda>W  s    @Q@Q&@Q@Q r+   r   )r   _preprocess_hooks_postprocess_hooksr   r4   r  r  r  )r6   
pre_backuppost_backupr  s       r)   test_pre_and_postprocess_hooksz-OperationTests.test_pre_and_postprocess_hooksS  s~    0
2'I'I&J	#(Q(Q'R	$iii  5))/UX???&0	#'2	$$$r+   c                 h   t          j        ddd          }t          j        |          }t          ||f          }t	          |d          }t          d                              |           |j        d         j        j        }t          j	        |t          j
        |          k              sJ d S )Nr   r   d   r   )max_samplesbokehr`   )r1   linspacesinr   r   r   get_plotr%   indexallsort)r6   r'   r   r  	decimatedr  s         r)   test_decimate_orderingz%OperationTests.test_decimate_ordering]  s    K2s##F1IIq!fU333	""9---r"'-verwu~~-.......r+   N)@__name__
__module____qualname____doc__r9   rL   rV   r]   rd   rl   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  da_skipr-  r2  r7  	ibis_skipr   markusefixturesrF  rH  rL  rP  rS  rW  rZ  rl  rp  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r`   r+   r)   r   r   3   s        
K K K
/ / /+ + +] ] ]
K K K
a a a
v v v
/ / // / /, , ,/ / /Y Y Y.Y Y Y0Y Y Y<	U 	U 	U/ / /
/ 
/ 
// / / - - -
R 
R 
RR R R - - -	5 	5 	5> > >( ( (( ( ( 	( 	( W	( 	( 	( W	( 
( 
( W
( [233( ( 43 Y( [233( ( 43 Y( [233( ( 43 Y(( ( (( ( (( ( (( ( (( ( (( ( (( ( (( ( (( ( (( ( (. . .
. . .. . .. . .
. . .. . .. . .
. . .. . .1 1 1G G G3 3 3/ / / / /r+   r   )-r   r   unittestr   numpyr1   pandasr?  r   r'  rk   r,  ImportErrorrB  	holoviewsr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   holoviews.core.data.gridr   holoviews.element.comparisonr   holoviews.operation.elementr   r   r   r   r   r   r   r   r  r  r   r`   r+   r)   <module>r     sM                        	BBBKKKK   DDD                                 3 2 2 2 2 2 ; ; ; ; ; ;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &t:
;
;F44<!899	r/ r/ r/ r/ r/' r/ r/ r/ r/ r/s    ))2 <<