
    eA                    v
   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlmZm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Zd dlZd dlZd dl m!Z! e"Z#e$Z%e"Z&d Z' ej(        d	          Z)e*e+ej,        fZ- e!ej.                  Z/ e!ej.                  Z0ej1        ej        ej2        ej        fZ3ej4        ej5        fZ6ej7        fZ8d
Z9dZ:e0 e!d          k    rddini Z; edd          Z<dZ=dZ>dZ?dZ@ e!ej.                  ZA	 eA e!d          k    rd dlBmCZD d dlEmFZGmHZH nJeA e!d          k    rd dlBmCZD d dlEmGZGmHZH n,eA e!d          k    rd dlBmDZD d dlEmGZGmHZH nd dlImDZD d dlJmGZGmHZH ejK        eDejL        fZMejN        fZOe3eMz   Z3e6eOz   Z6e8eHeGfz   Z8eA e!d          k    rd dlEmPZP e8ePfz   Z8eA e!d          k    r	d dlQmRZR eRfZ9n4# eS$ r,ZTejU        j        V                    deTz             Y dZT[TndZT[Tww xY w	 d dlWZWeWj        fZXe3eXz  Z3n# eY$ r d
ZXY nw xY wh dZZi e j[        de j\        d e j]        d!ej^        d"ej_        d#ej[        dej`        deja        d$ejb        d$ejc        d%ejd        d%eje        d&ejf        d&ejg        d'ejh        d'eji        d(ejj        d(ej\        d ejk        d ej]        d!ejl        d!ejm        d)ejn        d)ejo        d*ejp        d*iZq G d+ d,eS          Zr G d- d.ejs                  Zt et            Zud/ Zv G d0 d1ejw                  Zxd2 Zyd3 Zzd4 Z{ G d5 d6e          Z|d7 Z}d8 Z~d9 Zd: Zd; Zdd<Zd= Zd> Zd? Z G d@ dAejs                  Ze                                Ze                                Ze                                Ze                    dB          ZdC ZdD ZdE ZddGZ ej1        dH                              dI          ZdJ ZdK ZdL ZdM ZddNZddOZddPZddQZddRZddSZdT ZdU ZdV ZdW ZdX ZdY ZddZZd[ Zd\ Zd] Zd^ Zdd_Z G d` daej                  Zdb Zdc Zdd Zde Zdf ZddhZddiZddjZdk Zdl Zdm Zdn Zdo Zdp Zdq ZddrZds Zdt Zedu             Zdv Zdw ZddxZddyZddzZdd{Zdd|Zd} Zd~ Zd Zd Zd Zd Zd Z G d dejs                  ZddZd Zd Zd Zd Zd Zd ZddZddZddZddZd Zd ZddZddZd Zd Zd Zd ZddZd Zd ZdS )    N)defaultdict
namedtuple)contextmanager)partial)EventThread)FunctionType)Versionc                     | |k    | |k     z
  S N )abs     3lib/python3.11/site-packages/holoviews/core/util.py<lambda>r      s    AaC!A#;     varkwr   _2.0.0rc1
allow_refsFArgSpeczargs varargs keywords defaultsi@B z1.3.0)DatetimeTZDtype)ABCIndex	ABCSeriesz0.24.0)ABCIndexClassr   z0.20.0)DatetimeTZDtypeTypez0.23.0)ABCExtensionArrayz1.0)BaseMaskedArrayzYpandas could not register all extension types imports failed with the following error: %s>   standard	gregorianproleptic_gregoriansummaxminallanymeanprodstdvarmediancumprodcumsumc                   $     e Zd ZdZd fd	Z xZS )VersionErrorz0Raised when there is a library version mismatch.Nc                 X    || _         || _         t                      j        |fi | d S r   )versionmin_versionsuper__init__)selfmsgr1   r2   kwargs	__class__s        r   r4   zVersionError.__init__   s7    &'''''''r   NN)__name__
__module____qualname____doc__r4   __classcell__r8   s   @r   r/   r/      sC        66( ( ( ( ( ( ( ( ( (r   r/   c                      e Zd ZdZ ej        dd          Z ej        dd          Z ej        dd          Z	 ej        dd	          Z
 ej        d
d          Z ej        d
d          Z ej        d
d          Zd ZdS )Configz
    Set of boolean configuration values to change HoloViews' global
    behavior. Typically used to control warnings relating to
    deprecations or set global parameter such as style 'themes'.
    Fz1
       Whether to warn about future deprecationsdefaultdocgMbP?z
      The tolerance used to enforce regular sampling for regular,
      gridded data where regular sampling is expected. Expressed as the
      maximal allowable sampling difference between sample
      locations.z7
       Disable default padding (introduced in 1.13.0).Tz
       Whether to warn when the deprecated __call__ options syntax is
       used (the opts method should now be used instead). It is
       recommended that users switch this on to update any uses of
       __call__ as it will be deprecated in future.kbc_rz
       Global default colormap. Prior to HoloViews 1.14.0, the default
       value was 'fire' which can be set for backwards compatibility.a  
       Global default colormap for gridded elements (i.e. Image, Raster
       and QuadMesh). Can be set to 'fire' to match raster defaults
       prior to HoloViews 1.14.0 while allowing the default_cmap to be
       the value of 'kbc_r' used in HoloViews >= 1.14.0z
       Global default colormap for HeatMap elements. Prior to HoloViews
       1.14.0, the default value was the 'RdYlBu_r' colormap.c                 *     | j         j        di | | S Nr   )paramupdate)r5   paramss     r   __call__zConfig.__call__   s"    
##F###r   N)r:   r;   r<   r=   rH   Booleanfuture_deprecationsNumber
image_rtol
no_paddingwarn_options_callStringdefault_cmapdefault_gridded_cmapdefault_heatmap_cmaprK   r   r   r   rA   rA      s          (%- <4 5 5 5 e 2   J u 3: ; ; ;J &d 97 8 8 8  5< 6I J J JL (5< >; < < < (5< >A B B B    r   rA   c                 f    |                                  dz   dz  }|                     |dd          S )N   littleT)signed)
bit_lengthto_bytes)i	num_bytess     r   _int_to_bytesr^      s1    !#)I::i$:777r   c                   ,    e Zd ZdZej        fZdZd ZdS )HashableJSONa  
    Extends JSONEncoder to generate a hashable string for as many types
    of object as possible including nested objects and objects that are
    not normally hashable. The purpose of this class is to generate
    unique strings that once hashed are suitable for use in memoization
    and other cases where deep equality must be tested without storing
    the entire object.

    By default JSONEncoder supports booleans, numbers, strings, lists,
    tuples and dictionaries. In order to support other types such as
    sets, datetime objects and mutable objects such as pandas Dataframes
    or numpy arrays, HashableJSON has to convert these types to
    datastructures that can normally be represented as JSON.

    Support for other object types may need to be introduced in
    future. By default, unrecognized object types are represented by
    their id.

    One limitation of this approach is that dictionaries with composite
    keys (e.g. tuples) are not supported due to the JSON spec.
    r   c                    t          |t                    rt          t          |                    S t          |t          j                  rt          j        d          }|j        D ]$}|	                    t          |                     %|j        t          k    r@t          j                            d          }|                    |j        t"                    }|	                    |                                           |                                S t          |t(          j        t(          j        f          rt/          |          t0          k    r|                    t4          d          }	 t7          t(          j                            |d          j                  }n0# t>          $ r# tA          j!        |t@          j"                  g}Y nw xY wt          |t(          j                  r	|j#        g}nEt          |j$        t(          j%                  rd |j$        D             }nt7          |j$                  }||z   t7          |j&        j'                  z   }t          j(                    }|D ]N}t          |tR                    s"tU          |          +                    d          }|	                    |           O|                                S t          || j,                  rtU          |          S t          || j-                  rt]          |          S 	 t          |          S # t^          $ r ta          |          cY S w xY w)	Nmd5r   )size)nrandom_stateTindexc                     g | ]	}|D ]}|
S r   r   ).0colsnames      r   
<listcomp>z(HashableJSON.default.<locals>.<listcomp>   s%    IIIDDIID4IIIIr   utf-8)1
isinstancesethash	frozensetnpndarrayhashlibnewshaperI   r^   rc   _NP_SIZE_LARGErandomRandomStatechoiceflat_NP_SAMPLE_SIZEtobytes	hexdigestpdSeries	DataFramelen_PANDAS_ROWS_LARGEsample_PANDAS_SAMPLE_SIZElistutilhash_pandas_objectvalues	TypeErrorpickledumpsHIGHEST_PROTOCOLrk   columns
MultiIndexrg   namesrb   bytesstrencodestring_hashablerepr_hashablerepr	Exceptionid)	r5   objhsstate	pd_valuesr   all_valsvals	            r   rC   zHashableJSON.default   s   c3 
	!	#'''RZ(( 	!E""AY + +q))****x>))	--a00ll38/lBBHHS[[]]###;;== cBIr|455 	3xx,,,jj#6QjGGI !;!;Ct!;!L!L!STT		 I I I $\#v/FGGH			I #ry)) ,8*CK77 ,IICKIIIs{++ 7*T#)/-B-BBHA  !#u-- 3c((//'22C;;== T122 	s88OT/00 	99	99 	 	 	c77NNN	s$   33F' '*GGL. .M
	M
N)	r:   r;   r<   r=   dtdatetimer   r   rC   r   r   r   r`   r`      s=         * {nOM) ) ) ) )r   r`   c                     t          |           }|                                D ])\  }}||vri ||<   ||                             |           *|S )a  
    Update the old_opts option dictionary with the options defined in
    new_opts. Instead of a shallow update as would be performed by calling
    old_opts.update(new_opts), this updates the dictionaries of all option
    types separately.

    Given two dictionaries
        old_opts = {'a': {'x': 'old', 'y': 'old'}}
    and
        new_opts = {'a': {'y': 'new', 'z': 'new'}, 'b': {'k': 'new'}}
    this returns a dictionary
        {'a': {'x': 'old', 'y': 'new', 'z': 'new'}, 'b': {'k': 'new'}}
    )dictitemsrI   )old_optsnew_optsmergedoption_typeoptionss        r   merge_option_dictsr     sc     (^^F ( 0 0 , ,Wf$$"$F;{""7++++Mr   c                     i }| D ]8}t          |t                    r|}n|j        |j        i}t	          ||          }9|S )z{
    Given a collection of Option objects or partial option dictionaries,
    merge everything to a single dictionary.
    )rn   r   keyr7   r   )r   merged_optionsr   r   s       r   merge_options_to_dictr     sX    
 N F Fc$ 	-HH,H+NHEEr   c                    ddl m} t          |j                  d |D             }d}d}i }t	          |           dk    rt          | d         t                    rd}t          | d                                                 s6t          fd| d         	                                D                       rd}nt          | d         
                                          k    r	| d         }nO| d         }nF|r%|                    t                              rd}n|                    d	d          d}n| s|sd}|||fS )
z
    Utility to help with the deprecation of the old .opts method signature

    Returns whether opts.apply_groups should be used (as a bool) and the
    corresponding options.
       )Optionsc                     h | ]
}|d k    |S )cloner   )ri   kws     r   	<setcomp>z,deprecated_opts_signature.<locals>.<setcomp>4  s    11122==B===r   FNr   Tc              3      K   | ]?}t          |t                    o%t          |                                         p| V  @d S r   )rn   r   ro   issubset)ri   vgroupss     r   	<genexpr>z,deprecated_opts_signature.<locals>.<genexpr>;  sb       + + 1d##NSVV__V-D-D)D)MA + + + + + +r   r   )r   r   ro   _option_groupsr   rn   r   r   r%   r   keysget)argsr7   r   optsapply_groupsr   
new_kwargsr   s          @r   deprecated_opts_signaturer   +  sw    !     '((F11111DLGJ
4yy1}}DGT22}DG%%f-- 	 + + + +a))+ + + + +	 !LLa  F**aJJ1gGG	 $--F,, 	It	$	$	0 & *,,r   c                   \     e Zd ZdZd fd	Zed             Z fdZd Zd Z	d	 Z
d
 Z xZS )periodicz
    Run a callback count times with a given period without blocking.

    If count is None, will run till timeout (which may be forever if None).
    NFc                 v   t          |t                    r|dk     rt          d          n|t          d          |du r||t          d          t                                                       || _        || _        || _        d| _        || _	        || _
        t                      | _        d | _        d S )Nr   zCount value must be positivez.Count value must be a positive integer or NoneFzLWhen using a non-blocking thread, please specify either a count or a timeout)rn   int
ValueErrorr3   r4   periodcallbackcountcounterblocktimeoutr   
_completed_start_time)r5   r   r   r   r   r   r8   s         r   r4   zperiodic.__init__S  s    eS!! 	Oqyy
+I J JJyMNNNE>>em ; < < < 	 

''r   c                 4    | j                                         S r   )r   is_setr5   s    r   	completedzperiodic.completedh  s    %%'''r   c                     t          j                     | _        | j        du r"t                                                       d S |                                  d S NF)timer   r   r3   startrun)r5   r8   s    r   r   zperiodic.startl  sD    9;;:GGMMOOOOOHHJJJJJr   c                 F    d | _         | j                                         d S r   )r   r   ro   r   s    r   stopzperiodic.stops  s#    r   c                 R    d| j          d| j         dt          | j                   dS )Nz	periodic(, ))r   r   callable_namer   r   s    r   __repr__zperiodic.__repr__w  s1    W4;WW$*WWdm8T8TWWWWr   c                      t          |           S r   r   r   s    r   __str__zperiodic.__str__y  s    Dzzr   c                    | j         s| j        rt          j        | j                   n| j                            | j                   | xj        dz  c_        	 |                     | j                   n$# t          $ r | 
                                 Y nw xY w| j        :t          j                    | j        z
  }|| j        k    r| 
                                 | j        | j        k    r| 
                                 | j         d S d S Nr   )r   r   r   sleepr   r   waitr   r   r   r   r   r   r   )r5   r   s     r   r   zperiodic.run|  s   . 	z 2
4;''''$$T[111LLALLdl++++   		 |'ikkD$44$$IIKKK|tz))		! . 	 	 	 	 	s   A4 4BBr   )r:   r;   r<   r=   r4   propertyr   r   r   r   r   r   r>   r?   s   @r   r   r   L  s                    * ( ( X(      X X X        r   r   c                 x    	 t          t          j        | t          d                    S # t          $ r Y dS w xY w)z
    Given an object, return a hash using HashableJSON. This hash is not
    architecture, Python version or platform independent.
    T)cls	sort_keysN)rp   jsonr   r`   r   r   s    r   deephashr     sH    
DJsEEEFFF   tts   (+ 
99c                     | dk    rdS | d                                                                          du r| d         dk    rdS | d                                         S )a  
    Predicate that returns True for custom attributes added to AttrTrees
    that are not methods, properties or internal attributes.

    These custom attributes start with a capitalized character when
    applicable (not applicable to underscore or certain unicode characters)
     Tr   Fr   )upperisupper)
identifiers    r   tree_attributer     sd     Rt!}$$&&%//JqMS4H4Ht!}$$&&&r   c                     t           t                    rDt           t          j                  r*t          j         j                  }|j        dd         }n_t          j	                   rt          j                   }|j        }n.t           t                    rlt           j                  }t          j         j                  } fd|j        |d         D             }t          j         j                  r
|dd         }nt          j                   r$t          j                   }|j        dd         }nut           t                    r.t           t          j                  rt           j                  S t#                     rt           j                  S t%          d          t'          |          }t)          ||j        ||j                  S )aB  
    Returns an ArgSpec object for functions, staticmethods, instance
    methods, classmethods and partials.

    Note that the args list for instance and class methods are those as
    seen by the user. In other words, the first argument which is
    conventionally called 'self' or 'cls' is omitted in these cases.
    r   Nc                 &    g | ]}|j         v|S r   )keywords)ri   argcallable_objs     r   rl   zargspec.<locals>.<listcomp>  s&    VVVS@U5U5U5U5U5Ur   z/Cannot determine argspec for non-callable type.)r   varargsr   defaults)rn   type
issubclassrH   ParameterizedFunctioninspectgetfullargspecrK   r   
isfunctionr   r   funcismethodParameterizedargspecr4   callabler   get_keywordsr   r   r   )r   specr   arglenr   s   `    r   r  r    s    	<&& L|U%@AAL %l&;<<y}		L	)	) L%l33y	L'	*	* L\&''%l&788VVVVty1VVVL-.. 	8D		,	'	' L%l33y}	L$	'	' LJ|UEX,Y,Y L|,---	,		 L|,---JKKKD!!HdlXPTP]^^^^r   c                    | j         }| j        }d |D             }t          |          |j        r|j        ng }|r|j        dt          |                    n|j        }fd|D             }|j        t          |           d         }|j        Pt                    t          |j                  z
  }	|	r*d                    |	          }
t          d|d|
           t          |          t          |          t                    z   k    rt          d|d          |g k    rg S t          |          t          |          k    r|S t          |          t          |          k    r4|j        dt          |                   |k    rt          d|          |S |j
        rdS t          |          t          |          z
  rt          d|d	| d
|           t          |                              t          |                    r|S t          |                              t          ||z                       r|S |j        r|S t          t          ||z                       }t          d|d| d|           )a  
    Utility used by DynamicMap to ensure the supplied callback has an
    appropriate signature.

    If validation succeeds, returns a list of strings to be zipped with
    the positional arguments, i.e. kdim values. The zipped values can then
    be merged with the stream values to pass everything to the Callable
    as keywords.

    If the callbacks use *args, None is returned to indicate that kdim
    values must be passed to the Callable by position. In this
    situation, Callable passes *args and **kwargs directly to the
    callback.

    If the callback doesn't use **kwargs, the accepted keywords are
    validated against the stream parameter names.
    c                     g | ]	}|j         
S r   rk   )ri   kdims     r   rl   z,validate_dynamic_argspec.<locals>.<listcomp>  s    )))4TY)))r   Nc                     g | ]}|v|	S r   r   )ri   r   stream_paramss     r   rl   z,validate_dynamic_argspec.<locals>.<listcomp>  s#    FFFsS-E-Es-E-E-Er   ,z	Callable z/ missing keywords to accept stream parameters: zM accepts more positional arguments than there are kdims and stream parameterszRUnmatched positional kdim arguments only allowed at the start of the signature of z# accepts more positional arguments z than there are key dimensions z	Callback z signature over z% does not accommodate required kdims )r  rk   stream_parametersr   r   r   r   ro   joinKeyErrorr   r   r   )r   kdimsstreamsr  rk   r   all_posargsposargsr7   unassigned_streams
unassignedr   r  s               @r   validate_dynamic_argspecr    s   $ G=D))5)))E%g..M#*#3;wH3;M',X//KFFFFkFFFG\3x==.//*F //#gl2C2CC 	F"455J Et E E8BE E F F F 7||c%jj3}#5#5555 ?4 ? ? ? @ @ 	@{{	
5zzS\\!!	WU	#	#<U$// E<@E E F F F 	 2t	WE

	" 2 @4 @ @g @ @8=@ @ A A 	A	U		S[[	)	) 	2	U		S00	1	1 2		 2S(()) 14 1 15 1 1).1 1 2 2 	2r   c                 \   	 t          | t                    r!t          | t          j                  r| j        S t          | t          j                  rd| j        v r| j        j        S t          | t                    rt          |           S t          j        |           r| j        S t          j        |           r | j        j                            dd          S t          | t           j                  r| j        S t          |           j        S # t$          $ r t          |           cY S w xY w)zQ
    Attempt to return a meaningful name identifying a callable or generator
    	operationz	.__call__r   )rn   r   r   rH   r   r:   r  r  r   r   r   r   r  __func__r<   replacetypesGeneratorTyper   )r   s    r   r   r     s/   !|T** 	/<)DEE	/((u':;; 	/!333)22g.. 		/|$$$-- 	/((l++ 	/(5==k2NNNe&9:: 	/((%%.. ! ! !<     !s4   5D .D '#D D &3D  D ;D D+*D+c                 h   t          t          |dd          dd          dk    r|S t          |          }t          d |D                       }|dk    r|S |dk    rt          d          t	          |                                           }|                    t                    }|d|         }||dz   d         }|t	          |          t	          |          z   z
  }	|r9|d	         | j        v r*t	          | j	                  dz   t	          ||z             z
  }	|t          d          f|	z  z   |z   S )
a  
    Helper function to pad a __getitem__ key with the right number of
    empty slices (i.e. :) when the key contains an Ellipsis (...).

    If the vdim_selection flag is true, check if the end of the key
    contains strings or Dimension objects in obj. If so, extra padding
    will not be applied for the value dimensions (i.e. the resulting key
    will be exactly one longer than the number of kdims). Note: this
    flag should not be used for composite types.
    dtypeNkindr   c              3   ,   K   | ]}|t           u d V  dS r   N)Ellipsisri   ks     r   r   z#process_ellipses.<locals>.<genexpr>9  s&      @@a!x------@@r   r   r   z$Only one ellipsis allowed at a time.)getattr
wrap_tupler"   r   r   
dimensionsrg   r%  vdimsr  slice)
r   r   vdim_selectionwrapped_keyellipse_count	dim_countrg   headtailpadlens
             r   process_ellipsesr5  +  s9    wsGT**FD99S@@
S//K@@;@@@@@M
	!		>???CNN$$%%Ih''EvvDuQwxx D#d))c$ii/0F ;r?ci''#)nna'CT	NN:FE$KK>F*+d22r   c                 Z    t          | t                    r|                     d          S | S )z,
    Safely casts bytestring to unicode
    rm   )rn   r   decodevalues    r   bytes_to_unicoder:  K  s-     % %||G$$$Lr   c                 H    t          | t                    r| j        } | j        S )z9
    Gets the instance that owns the supplied method
    )rn   r   r  __self__)methods    r   get_method_ownerr>  T  s%     &'"" ?r   c                     |                      d          }|dk    r| S | |d                             dd                                          }|d                                         |dd         z   }| d|         |z   S )z
    Turns a string such as 'capital delta' into the shortened,
    capitalized version, in this case simply 'Delta'. Used as a
    transform in sanitize_identifier.
    capitalr(  Nr   r   r   )findr  stripr   )r   rg   r3  s      r   capitalize_unicode_namerC  ]  s|     FF9E{{1HUVV9Y++1133D7==??T!""X%DVeV9tr   c                   b   e Zd ZdZ ej        dd          Z ej        g dd          Z ej	        ddd	d
d          Z
 ej        egd          Z ej        g dd          Z ej        dd          Z ej	        i d          ZdZ ej	        i d          Zej        j        d             Zej        j        d             Zej        j        dd            Zej        j        d             Zej        j        d             Zej        j        d d            Zd!dZd Zd Zd ZdS )"sanitize_identifier_fna  
    Sanitizes group/label values for use in AttrTree attribute
    access.

    Special characters are sanitized using their (lowercase) unicode
    name using the unicodedata module. For instance:

    >>> unicodedata.name(u'$').lower()
    'dollar sign'

    As these names are often very long, this parameterized function
    allows filtered, substitutions and transforms to help shorten these
    names appropriately.
    Tz
       Whether the first letter should be converted to
       uppercase. Note, this will only be applied to ASCII characters
       in order to make sure paths aren't confused with method
       names.rB   )extendedaccentsmalllettersigndigitlatingreekzarabic-indicwithdollara  
       Lowercase strings to be eliminated from the unicode names in
       order to shorten the sanitized name ( lowercase). Redundant
       strings should be removed but too much elimination could cause
       two unique strings to map to the same sanitized output.powertimesover)
circumflexasterisksolidusaH  
       Lowercase substitutions of substrings in unicode names. For
       instance the ^ character has the name 'circumflex accent' even
       though it is more typically used for exponentiation. Note that
       substitutions occur after filtering and that there should be no
       ordering dependence between substitutions.a  
       List of string transformation functions to apply after
       filtering and substitution in order to further compress the
       unicode name. For instance, the default capitalize_unicode_name
       function will turn the string "capital delta" into "Delta".)trait_names_ipython_display__getAttributeNamesa  
       An explicit list of name that should not be allowed as
       attribute names on Tree objects.

       By default, prevents IPython from creating an entry called
       Trait_names due to an inconvenient getattr check (during
       tab-completion).Fze
       Whether leading underscores should be allowed to be sanitized
       with the leading prefix.za
       A dictionary of aliases mapping long strings to their short,
       sanitized equivalentsA_z2
       Cache of previously computed sanitizationsc                 r    | j                             d |                                D                        dS )z
        Conveniently add new aliases as keyword arguments. For instance
        you can add a new alias with add_aliases(short='Longer string')
        c                     i | ]\  }}||	S r   r   ri   r'  r   s      r   
<dictcomp>z6sanitize_identifier_fn.add_aliases.<locals>.<dictcomp>  s    #B#B#BCAaAa#B#B#Br   N)aliasesrI   r   )self_or_clsr7   s     r   add_aliasesz"sanitize_identifier_fn.add_aliases  s8     	""#B#B6<<>>#B#B#BCCCCCr   c                     | j                                         D ]#\  }}||v r| j                             |           $dS )z+
        Remove a list of aliases.
        N)r^  r   pop)r_  r^  r'  r   s       r   remove_aliasesz%sanitize_identifier_fn.remove_aliases  sQ    
 &,,.. 	+ 	+CAaG||#''***	+ 	+r   Nc                     g d}|| j         n|}|r                    d          rdS t          fd|D                       }| j        vo| S )N)	
javascriptjpegr   latexrg  pdfpngsvgmarkdownr   Fc              3   ,   K   | ]}d | dk    V  dS )_repr_r   Nr   )ri   elrk   s     r   r   z3sanitize_identifier_fn.allowable.<locals>.<genexpr>  s0      DDrNRNNNd*DDDDDDr   )disable_leading_underscore
startswithr&   
disallowed)r_  rk   ro  disabled_reprs	disabled_isreprs    `    r   	allowablez sanitize_identifier_fn.allowable  s    C C C~ 29  ::3   ,, DDDD^DDDDDv;11A6zAr   c                 p    g d}|                     d          rdS t          j        |d                   |v S )z
        Whether or not the identifier will be prefixed.
        Strings that require the prefix are generally not recommended.
        )MnMcNdPcr   Tr   )rp  unicodedatacategory)r5   r   invalid_startings      r   prefixedzsanitize_identifier_fn.prefixed  sC     433  %%3tt#JqM226FFFr   c                     d}|D ]I}t          j        d|                              dd          }|dk    r|t          |          z  }D||z  }J|S )ze
        Remove diacritics and accents from the input leaving other
        unicode characters alone.r   NFKDASCIIignore)r{  	normalizer   r:  )r_  r   charscreplacements        r   remove_diacriticsz(sanitize_identifier_fn.remove_diacritics  sj    
  	 	A%/::AA'8TTKb  )+666
r   c                    |g }|i }|g }t          j        |                                          }|D ]}|                    |d          }|                                D ]\  }}|                    ||          }|D ]}	 |	|          }d                    |                                                                                              dd                              dd          S )z
        Given a unicode character c, return the shortened unicode name
        (as a list of tokens) by applying the eliminations,
        substitutions and transforms.
        Nr    r   -)r{  rk   lowerr  r   r  rB  split)
r_  r  eliminationssubstitutions
transformsrk   elimr\   o	transforms
             r   shortened_character_namez/sanitize_identifier_fn.shortened_character_name  s     J ML""((**  	* 	*D<<b))DD &&(( 	& 	&CAa<<1%%DD# 	# 	#I9T??DDxx

**,,--55c#>>FFs3OOOr   c                    |dv r|S || j         v r| j         |         S || j        v r| j        |         S t          |          }|                     |          st	          d|d| j                  | j        r;|r9|d         t          j        v r%|d         	                                |dd          z   }| 
                    |          }|                     |          r
| j        |z   }|| j        |<   |S )N)Nr   zString z/ is in the disallowed list of attribute names: r   r   )r^  _lookup_tabler:  ru  AttributeErrorrq  
capitalizestringascii_lowercaser   sanitize_py3r~  prefix)r5   rk   escape	sanitizeds       r   rK   zsanitize_identifier_fn.__call__  s   :;T\!!<%%T'''$T**%%~~d## 	w !u4!u!ubfbq!u!uvvv? 	,t 	,Q63I(I(I7==??48+D%%d++	== 	/{Y.9#,4 r   c                 T   d t          j        |d           D             }d |D             }g }|D ]v}|dk    r	|                    d          rt          |dd                   }|                    d          rt          |dd                   }|                    |           w|S )z?Strip underscores to make sure the number is correct after joinc                 |    g | ]9\  }}|r#t          d                     |                    gnt          |          :S )r   )r   r  r   )ri   r   rn  s      r   rl   z?sanitize_identifier_fn._process_underscores.<locals>.<listcomp>  sW     M M Mq )*73rwwr{{##$$tBxx M M Mr   c                     | dk    S Nr   r   )r'  s    r   r   z=sanitize_identifier_fn._process_underscores.<locals>.<lambda>  s
    AsF r   c                     g | ]	}|D ]}|
S r   r   )ri   grouprn  s      r   rl   z?sanitize_identifier_fn._process_underscores.<locals>.<listcomp>  s%    <<<Ee<<R<<<<r   r   r   Nr(  )	itertoolsgroupbyrp  r   endswithappend)r5   tokensr   	flattened	processedtokens         r   _process_underscoresz+sanitize_identifier_fn._process_underscores  s    M M ) 1&:J:J K KM M M<<V<<<		 	$ 	$E||h$$ 'E!""I~~c"" (E#2#JU####r   c                     |                                 s*d                    |                     |d                     S |S )Nr   c                 0    d| z                                    S r  )isidentifier)r  s    r   r   z5sanitize_identifier_fn.sanitize_py3.<locals>.<lambda>"  s    3q5:N:N:P:P r   )r  r  sanitize)r5   rk   s     r   r  z#sanitize_identifier_fn.sanitize_py3   s?      "" 	88DMM$0P0PQQRRRKr   c                 H   dddddd}t          fd|                                          D ]}t          d||         z            g d	}}                                D ]}|D ]} ||          r||d
k    rt	          |          n|z  }(|                     || j        | j        | j                  }	|	                    |r|gng            |	d	k    r|
                    |	           d	}|r|	                    |g           d	}|                     ||r|gng z             S )z;Accumulate blocks of hex and separate blocks by underscoresr   r   r   fr)c                     | v S r   r   )rn  rk   s    r   r   z1sanitize_identifier_fn.sanitize.<locals>.<lambda>)  s    B$J r   z4Please use a raw string or escape control code '\%s'r   r   )filterr   r   r  r   r  r  r  r  extendr  r  )
r5   rk   valid_fninvalidccr  r  r  r  shorts
    `        r   r  zsanitize_identifier_fn.sanitize&  st   3CSAA....?? 	+ 	+BS%bk* + + +r5	ZZ\\ 	 	E 	 	8A;; 1c66Qq @ 99!T=N9=9K9=J JE $$%=eWW2>>>{{ ''...EE   %)))((6NuggB)OPPPr   r   )NNNT)r:   r;   r<   r=   rH   rL   r  Listr  Dictr  rC  r  rq  ro  r^  r  r  parameterized
bothmethodr`  rc  ru  r~  r  r  rK   r  r  r  r   r   r   rE  rE  j  s         t 2   J 5: 'S 'S 'SYBC C CL EJW3:28(: (:@56 6 6M %<$= DF G G GJ  %; %; %;A  J "/u C# "$ "$ "$ ej *  ! ! !G FEJr 05 6 6 6M #D D $#D #+ + $#+ #	B 	B 	B $#	B #G G $#G #  $# #P P P $#P0   *     Q Q Q Q Qr   rE  r  c                 \    | du p(t          j        |           pt          | t                    S )z!
    Value is scalar or None
    N)rr   isscalarrn   datetime_typesr   s    r   r  r  D  s,     $;M"+c**Mjn.M.MMr   c                     t          | t          t          t          j        f          rdS 	 t          |            dS # t          $ r Y dS w xY w)NFT)rn   r   boolrr   bool_floatr   r  s    r   	isnumericr  K  sY    #T28,-- uc


t   uus   < 
A
	A
c                     	 | |u p| |k    }t          |t                    s$t          |d          r|                                }t          |          S # t          $ r Y dS w xY w)zsCompare two values, returning a boolean.

    Will apply the comparison to all elements of an array/dataframe.
    r%   F)rn   r  hasattrr%   r   )value1value2checks      r   isequalr  U  sy    
6!8v'7%&& 	 75%+@+@ 	 IIKKEE{{   uus   AA 
A"!A"Tc                    t          | t          j                  r| S t          | t                    rt          j        | t
                    S t          | t          j                  st          | t                    r| j        S t          | d          rt          j        |           S |r t          dt          |            d          | S )z
    Converts arraylike objects to NumPy ndarray types. Errors if
    object is not arraylike and strict option is enabled.
    r!  	__array__zCould not convert z type to array)rn   rr   rs   r   asarrayobjectarraylike_typesr   r  r   r   )	arraylikestricts     r   r  r  c  s    
 )RZ(( 	O	It	$	$ Oz)62222	2:.. O:i3Y3Y O	K	(	( Oz)$$$	 OMd9ooMMMNNNr   NATi8c                    t          | t          j        t          j        f          s*t          | t          j                  rZ| j        j        dk    rJt          t          d          k    rt          j	        |           S | 
                    d          t          k    S | t          j        u rdS t          | t          t          z             rt          j        |           S dS )zV
    Checks if the value is a NaT. Should only be called on datetimelike objects.
    Mz1.13r  TF)rn   rr   
datetime64timedelta64rs   r!  r"  numpy_versionr
   isnatviewnat_as_integerr   NaTpandas_datetime_typespandas_timedelta_typesisnar  s    r   r  r  w  s     	3788 	C	$	$),3)>)>GFOO++8C== 88D>>^33	t	C./EE	F	F ws||ur   c                    t          |           }t          j        |           s|st          | t          j        j        j                  r| j         t          | j	                  z  S t          | t                    r*|                                  t          | j                  z  S t          | d          } | dS |rddlm} |                    |           S t          | t          j                  r| j        j        dk    rt'          |            S | j        j        dk    r%t          j        d | D             t(                    S | j        j        d	v rt+          j        |            S t          j        |           }t,          t/          d
          k    r|t+          j        |            z  }|S t          | t0          t2          z             rt'          |            S t          | t4          t6          f          rdS t          j        |           }t,          t/          d
          k    r:|t*          j        u rdS |t+          j        t          j        |                      z  S |S )z
    Helper function to determine if scalar or array value is finite extending
    np.isfinite with support for None, string, datetime types.
    F)r  Nr   r  Oc                 ,    g | ]}t          |          S r   )isfiniteri   r   s     r   rl   zisfinite.<locals>.<listcomp>  s    666QXa[[666r   r  USz1.0.0T)is_dask_arrayrr   r  rn   macoreMaskedArraymaskr  datamasked_typesr  _datar  
dask.arrayarrayrs   r!  r"  r  r  r   pandas_versionr
   r  timedelta_typesr   r   NA)r   is_daskdafinites       r   r  r    s*   
 C  G;s )G )c25:122 	5H9x1111\** 	5HHJJ;#)!4!444c%(((
{u	 {{3	C	$	$ 9>S  #JJ;Y^s""866#666dCCCCY^t##GCLL= S!!WW----rws||m#F	C7	8	8 ::~	C#u	&	& t[F))))RU??5C11111Mr   c                     t          | t          j                  rJ| j        j        dk    p9| j        j        dk    o)t          |           ot          | d         t                    S t          | t                    S )zB
    Whether the array or scalar is recognized datetime type.
    r  r  r   )rn   rr   rs   r!  r"  r   r  r8  s    r   
isdatetimer    sq     %$$ 1 C' 7!S( 6SZZ 6E!Hn55	8 %000r   c                    	 t          t          |           t          |          t          j        t          j        g          }t          d |D                       }n(# t          $ r t          j        t          j        f}Y nw xY w|S )z
    Takes (a1, a2) and (b1, b2) as input and returns
    (np.nanmin(a1, b1), np.nanmax(a2, b2)). Used to calculate
    min and max values of a number of items.
    c                 J    g | ] \  }}}t           |||g                    !S r   )r  )ri   lolfns       r   rl   zfind_minmax.<locals>.<listcomp>  s2    CCCyq"bbb!Rkk**CCCr   )zipr   rr   nanminnanmaxtupler   nan)limsolimslimziplimitss       r   find_minmaxr    s}    "T$ZZery").DEECCFCCCDD " " "&"&!"Ms   AA "BBc                    |g }	 t          j        |           } t          | j                  dk    rt          j        |           n| } t          |          rt          j        | |g          } | j        j        dk    r(|                                 | 	                                fS t          j                    5  t          j        dd           t          j        |           t          j        |           fcddd           S # 1 swxY w Y   dS # t          $ r5 	 t!          |           } | d         | d         fcY S # t          $ r Y Y dS w xY ww xY w)	z
    Safely finds either the numerical min and max of
    a set of values, falling back to the first and
    the last value in the sorted list of values.
    Nr   r  r   All-NaN (slice|axis) encounteredr   r(  r9   )rr   r  r   rv   squeezeconcatenater!  r"  r$   r#   warningscatch_warningsfilterwarningsr	  r
  r   sorted)r   
soft_ranges     r   
find_ranger    s    
 &!!'*6<'8'81'<'<F###&z?? 	:^VZ$899F<##::<<--$&& 	8 	8#H.QRRR9V$$bi&7&77	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8       	 F^^F1Ivbz**** 	  	  	 <<<	 	 sZ   BD %D 8=D5D DD 	D
D 
ED;8E;
E
E	E

Ec                 r   	 t          j                    5  t          j        dd           d | D             }t          d |D                       rg }|D ]\  }}t	          |t
          j                  rgt	          |t
          j                  rM|                                                                }|                                                                }nvt	          |t                    rat	          |t                    rLt          j
        |                                          t          j
        |                                          }}|                    ||f           |}t          j        |          }t          |          s$t          j        t          j        fcddd           S |j        j        dv rBt%          t'          d |D                                 }|d         |d	         fcddd           S |j        j        d
v rt|r(|                                |                                fn;|dddf                                         |dddf                                         f}|cddd           S |r4t          j        |          t          j        |          fcddd           S t          j        |dddf                   t          j        |dddf                   fcddd           S # 1 swxY w Y   dS # t0          $ r t          j        t          j        fcY S w xY w)ao  
    Computes the maximal lower and upper bounds from a list bounds.

    Args:
       ranges (list of tuples): A list of range tuples
       combined (boolean, optional): Whether to combine bounds
          Whether range should be computed on lower and upper bound
          independently or both at once

    Returns:
       The maximum range as a single tuple
    r  r  c                 @    g | ]}t          d  |D                       S )c              3   6   K   | ]}|t           j        n|V  d S r   )rr   r  r  s     r   r   z'max_range.<locals>.<listcomp>.<genexpr>  s,      BB1aiBFFQBBBBBBr   )r  )ri   r  s     r   rl   zmax_range.<locals>.<listcomp>  s/    SSSqeBBBBBBBSSSr   c              3      K   | ]B}|D ]=}t          |t                    o#t          |t          t          j        fz              V  >Cd S r   )rn   r  cftime_typesr   r   ri   r  r   s      r   r   zmax_range.<locals>.<genexpr>  sr       6 616 6./ a00_A|UWU\T^G^9_9_5_ 6 6 6 6 6 6 6r   NOSUc                 >    g | ]}|D ]}t          |          s||S r   is_nanr!  s      r   rl   zmax_range.<locals>.<listcomp>  sD     (8 (8 (8q(8 (8*+!!99(8)* )6r   r   r(  r  r   )r  r  r  r&   rn   r   Periodto_timestampto_datetime64r  	Timestampr  rr   r  r   r  r!  r"  r   python2sortr$   r#   r	  r
  r   )rangescombinedr   	convertedr  r   arrdranges           r   	max_ranger0    s   # $&&  	D  	D#H.QRRRSSFSSSF 6 6#)6 6 6 6 6 #	" - -DAq!!RY// AJq")4L4L ANN,,::<<NN,,::<<#A~66 A:a;X;X A "Q = = ? ? "Q = = ? ? $$aV,,,,"(6""Cs88 
vrv~% 	D  	D  	D  	D  	D  	D  	D  	D& 5((; (8 (8%(8 (8 (8 9 9 : : 1vs2w/ 	D  	D  	D  	D  	D  	D  	D  	D0 3&&4< =37799cggii00qqq!t9==??C1IMMOO< 7 	D  	D  	D  	D  	D  	D  	D  	D:  D	#	#7= 	D  	D  	D  	D  	D  	D  	D  	D@ 	#aaad),,biAAAqD	.B.BCA 	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	D  	DB        sg   L FL'L 4AL7L A5L9L )L/L <;L7L LL LL "L65L6c                 h   |t          |t                    s||f}t          |           rt          |          rp|mt          | t                    s|r| dk    r|dk    rt	          j        |           t	          j        d          z  }t	          j        |          t	          j        d          z  }||z
  d|d         dz  z   z  }||z
  d|d         dz  z   z  }||z   dz  }t	          j        d||dz  z
            t	          j        d||dz  z             }
}	nt          | t                    rVt          | t                    sAt	          j        |           t	          j        |          }} || z
  	                    d          }n|| z
  }||d         z  }||d         z  }| |z
  ||z   }
}	n| |}
}	|	|
fS )z6
    Pads the range by a fraction of the interval
    Nr   
   r             @z>m8[ns])
rn   r  	is_numberr  rr   logrP  r   r  astype)r  r   paddingr6  log_minlog_maxlspanuspancenterr   endspanlpadupads                 r   	range_padrB    s    :gu#=#=G$ "Ie,, "1D%00 	0S 	0UQYY5ST99fUmmbfRjj0GfUmmbfRjj0GW_qA~6EW_qA~6Ego,F"fU2Xo66VERTH_8U8U3EE%00 %E<9X9X %!}U33R]55I5Iue++I66e$D$DtU4Z3EEEs#:r   c                    t          | |||          \  }}t          |d                   r|d         | k    r	|d         } n!t          |df|d         dfg          d         } t          |d                   r|d         |k    r	|d         }n!t          d|fd|d         fg          d         }|\  }}	|t          |          s| n|} |	t          |	          s|n|	}| |fS )zw
    Computes the range along a dimension by combining the data range
    with the Dimension soft_range and range.
    r   Nr   )rB  r  r0  )
r  r   
hard_ranger  r8  r6  plowerpupperdmindmaxs
             r   dimension_rangerI  7  s    
 ueWc::NFF
1 F:a=E#9#91FD>JqM4+@ABB1E
1 F:a=E#9#91D&>D*Q-+@ABB1EJD$\$\EETE\$\EETE%<r   c                    |rd}g d}d | D             } nd}ddg}| rt          t          |            ng }t          j        g|z  } t	          |          dk    r| S t          j                    5  t          j        dd	           |D ]5\  }}d
 ||         D             }d ||         D             }|r3t          |d         t                    rt          j
        |          | |<   nPt          d |D                       rt          j        |          d         | |<   n|rt          j        |          | |<   |r3t          |d         t                    rt          j        |          | |<   t          d |D                       rt          j        |          d         | |<   |rt          j        |          | |<   7	 ddd           n# 1 swxY w Y   t!          |           S )z
    Computes the maximal extent in 2D and 3D space from
    list of 4-tuples or 6-tuples. If zrange is enabled
    all extents are converted to 6-tuples to compute
    x-, y- and z-limits.
       ))r      )r      )r3     c                 x    g | ]7}t          |          d k    r|n|d         |d         d|d         |d         df8S )rK  r   r   Nr3  rL  r   )ri   es     r   rl   zmax_extents.<locals>.<listcomp>U  sZ     % % % A!11!A$!d*+A$!d*< % % %r   rM  )r   r3  )r   rL  r   r  r  c                 4    g | ]}|t          |          |S r   r$  r  s     r   rl   zmax_extents.<locals>.<listcomp>b  #    MMM1Q]6!99]Q]]]r   c                 4    g | ]}|t          |          |S r   r$  r  s     r   rl   zmax_extents.<locals>.<listcomp>c  rS  r   c              3   @   K   | ]}t          |t                    V  d S r   rn   r   )ri   r  s     r   r   zmax_extents.<locals>.<genexpr>f  ,      77AZ3''777777r   c              3   @   K   | ]}t          |t                    V  d S r   rV  )ri   us     r   r   zmax_extents.<locals>.<genexpr>l  rW  r   r(  N)r   r  rr   r  r   r  r  r  rn   r  r$   r&   sortr	  r#   r
  r  )	extentszrangenumindsr.  lidxuidxr  r   s	            r   max_extentsra  K  sZ      '''% %#% % % !(
0$sG}


bCvhnG
3xx1}}		 	"	" 1 1*MNNN 	1 	1JD$MMD	MMMEMMD	MMME 1E!Hn== 1 "u7777777 1 "q 1 1 "	% 0 0 1E!Hn== 1 "u7777777 1 "r 2 1 "	% 0 0	11 1 1 1 1 1 1 1 1 1 1 1 1 1 1" >>s   .EG

GGc                 H   |rdnd}d}d}| dk    rt          t          | |z                       S | dk    rc| dz  | }}t          |          D ]}|dz  }|dz  }|dk    r|}n|}|t          t          ||z                       z  }|dz  }| d|z  z  } | dk    c|ddd         S )	z5Generates alphanumeric labels of form A-Z, AA-ZZ etc.A   a   r   r      r   Nr(  )r   chrrange)	rd   r   casenumlabelr   moddivr   r   s	            r   int_to_alpharl  s  s    !bbrGEEAvvc#a'k**+++
q&&r61Su 	 	ABJCCr	A::CCCSw''(((
	RY q&& 2;r   c                 \   t          | t                    st          dt          |                      d| cxk     rdk     sn t	          d          d}d}d}t          t          |                    D ]6}t          | ||         z            }|||         |z  z  }| ||         |z  z  } 7|S )Nzexpected integer, got r   i  z#Argument must be between 1 and 3999)i  i  i  i  d   Z   2   (   r2  	   rN  rM  r   )r  CMDCDCXCLXLXIXVIVIr   )rn   r   r   r   r   rg  r   )inputintsnumsresultr\   r   s         r   int_to_romanr    s    
UC
 
  ><tE{{<<===
e



d



<===
I4
J46#d))  q%$q'/""eQ%ftAwee
=r   c              #   j   K   t                      }| D ]}||vr|                    |           |V   dS )z^
    Returns an iterator containing all non-duplicate elements
    in the input sequence.
    N)ro   add)seqseenitems      r   unique_iteratorr    sN      
 55D  tHHTNNNJJJ r   c                  .    t          t          |            S )z+
    zip function that returns a list.
    )r   r  r   s    r   lzipr    s     T
r   c                  H    t          t          t          |                      S )z1
    Returns a unique list of zipped values.
    )r   r  r  r  s    r   
unique_zipr    s     T
++,,,r   c                 t   t          |           st          j        |           S t          | t          j                  r"| j        j        dvrt          j        |           S g }| D ]}t          |t                    r<t          |t                    s't          j        |                                          }n5t          t          |dd          t          j                  r|j        j        }|                    |           t          j        t          j        |                                                    S )z
    Returns an array of unique values in the input order.

    Args:
       arr (np.ndarray or list): The array to compute unique values on

    Returns:
       A new array of unique values
    MOr!  N)r   rr   r  rn   rs   r!  r"  r   uniquer  r   r)  r(  r)  CategoricalDtype
categoriesr  ravel)r.  r   r   s      r   unique_arrayr    s	    s88 z##rz"" sy~T'A'Ay~~F  q.)) 	#1l++	#Q--//AA7D1123FGG 	#"Aa9RZ''--//000r   c                     d}|                     di           }t          |           j        t          | j        d          t          | j        d          fD ]}||fz  }||v r||         }|S )z
    Matches the group.label specification of the supplied
    element against the supplied specification dictionary
    returning the value of the best match.
    r   F)r  )r   r   r:   group_sanitizerr  label_sanitizerri  )elementspecificationmatch_tuplematchr  s        r   
match_specr    s     Kb"%%Eg' u=== u===? / / 	w-''!+.ELr   c                    t          |           dk    r| S t          |           }t          |          gg}|D ]t}|D ]Y}	 |n
 |          }|d         n |d                   }||k      |                    |            n&# t          $ r Y Vw xY w|                    |g           ut
          j                            fd|D                       S )Nr   c              3   :   K   | ]}t          |           V  dS )r   Nr  )ri   r  r   s     r   r   zpython2sort.<locals>.<genexpr>  s0      (T(TE3)?)?)?(T(T(T(T(T(Tr   )r   iternextr  r   r  chainfrom_iterable)xr   itr   r  r  item_precedencegroup_precedences    `      r   r*  r*    s   
1vv{{1H	aBBxxj\F " " 
	" 
	"E*-+$$33t99/2{588E!H "222T"""    MM4&!!!?(((T(T(T(TV(T(T(TTTTs    AB
BBc                    t          t                    g }| D ]E}|D ]@}|j                                     |j                   ||vr|                    |           AFd                                 D             fd|D             S )a  
    Merges lists of fully or partially overlapping dimensions by
    merging their values.

    >>> from holoviews import Dimension
    >>> dim_list = [[Dimension('A', values=[1, 2, 3]), Dimension('B')],
    ...             [Dimension('A', values=[2, 3, 4])]]
    >>> dimensions = merge_dimensions(dim_list)
    >>> dimensions
    [Dimension('A'), Dimension('B')]
    >>> dimensions[0].values
    [1, 2, 3, 4]
    c           
      f    i | ].\  }}|t          t          t          j        |                     /S r   )r   r  r  r  )ri   r'  valss      r   r]  z$merge_dimensions.<locals>.<dictcomp>  sE     / / /1d $y'=>>?? / / /r   c                 n    g | ]1}|                                         |j        g                      2S ))r   )r   r   rk   )ri   ddvaluess     r   rl   z$merge_dimensions.<locals>.<listcomp>  s7    HHHAGG7;;qvr22G33HHHr   )r   r   rk   r  r   r   )dimensions_listr+  dimsr  r  s       @r   merge_dimensionsr    s     $GJ % % 	% 	%AAFO""18,,,
""!!!$$$	%/ /%mmoo/ / /GHHHHZHHHHr   c                 4   i }t          |          ||z   fd|D             d D             t          t          |                    t          |          k    rt          d          fd|d<   t          |                                 fi |S )z
    Sorts data by key using usual Python tuple sorting semantics
    or sorts in categorical order for any categorical Dimensions.
    c           	          g | ]?}|         t          |t                    v          |t                    v r|n|z
  f@S r   )r   rg  )ri   r\   r+  ndimss     r   rl   z"dimension_sort.<locals>.<listcomp>  sb     $ $ $ 1s1E%LL#899eEll**AA%9 $ $ $r   c                 J    i | ] }|j         d gt          |j                  z   !S r   )rk   r   r   ri   r  s     r   r]  z"dimension_sort.<locals>.<dictcomp>  s+    GGGqQVdVDNN2GGGr   z$Cannot sort on duplicated dimensionsc                 X     t           fdt                    D                       S )Nc              3      K   | ]L\  }\  }}}|j         r,|j                                     |         |                   n|         |         V  Md S r   )r   rk   rg   )ri   r\   dimtr  cached_valuesr  s        r   r   z3dimension_sort.<locals>.<lambda>.<locals>.<genexpr>  s~       (R (R,:A{Q ,/:)Cch(?(E(Ead1g(N(N(N;<Q47(R (R (R (R (R (Rr   )r  	enumerate)r  r  indexess   `r   r   z dimension_sort.<locals>.<lambda>  sO    % (R (R (R (R (R>G>P>P(R (R (R #R #R r   r   )r   ro   r   r*  r   )	odictr  r,  	key_indexsortkwsr  r+  r  r  s	        @@@@r   dimension_sortr    s    
 GJJEuJ$ $ $ $ $"$ $ $G HGJGGGM
3y>>c)nn,,?@@@R R R R Rwu~ u{{}}00000r   c                 B   t          | t          j                  rdS t          | t          j                  rdS t          j        d         dk     rt          | t          j                  rdS t          | d          rt          | d          rdS t          | d          rdS dS )NTFr   2__int____add__qdiv)rn   numbersrN   rr   str___version__unicode_r  r   s    r   r5  r5  "  s    #w~&& tt	C	!	! %%		S	 	 ZR[%A%A	 %% #y
!
! gc9&=&= tt	f		 ddr   c                 D    t          | t          t          j        f          S )z<
    Checks if the argument is a floating-point scalar.
    )rn   r  rr   floatingr   s    r   is_floatr  .  s     cE2;/000r   c                     t          | t                    p!t          t          | dd          dd          dv }|s&|r&t          | d          r|                                 rdS dS )	a,  
    Checks for int types including the native Python type and NumPy-like objects

    Args:
        obj: Object to check for integer type
        int_like (boolean): Check for float types with integer value

    Returns:
        Boolean indicating whether the supplied value is of integer type.
    r!  Nr"  r  ui
is_integerTF)rn   r   r)  r  r  )r   int_likereal_ints      r   is_intr  5  sr     #s##`wwsGT/J/JFTW'X'X\`'`H H l!;!; @P@P t5r   c                   b    e Zd ZdZ ej        dd          Z ej        ddd          Zd	 Z	d
S )ProgressIndicatorze
    Baseclass for any ProgressIndicator that indicates progress
    as a completion percentage.
    )g        g      Y@a   
        The total percentage spanned by the progress bar when called
        with a value between 0% and 100%. This allows an overall
        completion in percent to be broken down into smaller sub-tasks
        that individually complete to 100 percent.rB   ProgressTz/
        The label of the current progress bar.)rC   
allow_NonerD   c                     t           r   )NotImplementedError)r5   
completions     r   rK   zProgressIndicator.__call__U  s    !!r   N)
r:   r;   r<   r=   rH   NumericTuplepercent_rangerR   ri  rK   r   r   r   r  r  F  st         
 'E&| B6 7 7 7M EL C2 3 3 3E" " " " "r   r  c                      i t          t                    fd fd} D ]} ||           t          t          j        d fdt          j                    D                                 S )z
    Stackless topological sorting.

    graph = {
        3: [1],
        5: [3],
        4: [2],
        6: [4],
    }

    sort_topologically(graph)
    [[1, 2], [3, 4], [5, 6]]
    c                 H    || <   |                              |            d S r   )r  )rk   levellevels_by_namenames_by_levels     r   add_level_to_namez-sort_topologically.<locals>.add_level_to_namej  s,    $tu$$T*****r   c                 \   | g}|r|                                 } | v r| vs|          sd} | |           6|          }fd|D             }|r+|                    |            |                    |           ydt          fd|D                       z   } | |           |d S d S )Nr   c                     g | ]}|v|	S r   r   )ri   childr  s     r   rl   z@sort_topologically.<locals>.walk_depth_first.<locals>.<listcomp>}  s$    &b&b&beSaFaFauFaFaFar   r   c              3   (   K   | ]}|         V  d S r   r   )ri   lnamer  s     r   r   z?sort_topologically.<locals>.walk_depth_first.<locals>.<genexpr>  s(      HHeN51HHHHHHr   )rb  r  r  r#   )rk   stackr  childrenchildren_not_calculatedr  graphr  s        r   walk_depth_firstz,sort_topologically.<locals>.walk_depth_firsto  s    	+99;;D~%%5  d !!$...T{H&b&b&b&b(&b&b&b#& T"""4555HHHHxHHHHHHEdE***'  	+ 	+ 	+ 	+ 	+r   c                 
    | d uS r   r   r  s    r   r   z$sort_topologically.<locals>.<lambda>  s
    atm r   c              3   D   K   | ]}                     |d           V  d S r   )r   )ri   r\   r  s     r   r   z%sort_topologically.<locals>.<genexpr>  sO       %A %A)* &4%7%74%@%@ %A %A %A %A %A %Ar   )r   r   r  	takewhiler   )r  r  rk   r  r  r  s   `  @@@r   sort_topologicallyr  Y  s     N &&N+ + + + + +
+ + + + + + +.   	#$;$;%A %A %A %A.7o.?.?%A %A %AB B C C Cr   c                 h     t                       fdt          fd D                       S )z
    Return True if the directed graph g has a cycle. The directed graph
    should be represented as a dictionary mapping of edges for each node.
    c                                          |                                | d          D ]}|v s |          r dS                     |            dS )Nr   TF)r  r   remove)vertex	neighbourr  pathvisits     r   r  zis_cyclic.<locals>.visit  so    62.. 	 	ID  EE)$4$4 tt !Fur   c              3   .   K   | ]} |          V  d S r   r   )ri   r   r  s     r   r   zis_cyclic.<locals>.<genexpr>  s+      ''AuuQxx''''''r   )ro   r&   )r  r  r  s   `@@r   	is_cyclicr    sX    
 55D       ''''''''''r   c                     t           j                            |                                           }t	          |           t	          |          k    o,t	          t          |                    t	          |          k    S )z
    Return True if graph contains only one to one mappings. The
    directed graph should be represented as a dictionary mapping of
    edges for each node. Nodes should be passed a simple list.
    )r  r  r  r   r   ro   )r  nodesedgess      r   
one_to_oner    sT     O))%,,..99Eu::U#ECJJ3u::(EEr   c                     t          |          }t          | j                  r$t          |          j        |j        |j        f|z   nt          |          j        f|z   S )zM
    Gets the type.group.label + key spec from an Element in an Overlay.
    )r*  r   r  r   r:   r  ri  )r  r'  r   s      r   get_overlay_specr    sV     	1A8;AG $T!WWqw0144!WW!#%r   c           	      J   i }| D ]fdj                                         D             }t          |          dk    r|d         |vrg ||d         <   P|                    d t	          |dd         |          D                        d t          |          D             S )zT
   Find a global ordering for layers in a HoloMap of CompositeOverlay
   types.
   c                 8    g | ]\  }}t          ||          S r   )r  )ri   r'  r   r  s      r   rl   zlayer_sort.<locals>.<listcomp>  s*    DDDTQ1a((DDDr   r   r   c                 ,    i | ]\  }}|||k    rg n|gS r   r   r\  s      r   r]  zlayer_sort.<locals>.<dictcomp>  s,    VVV11AFFbbVVVr   Nc                 6    g | ]}t          |          D ]}|S r   r  )ri   gr\   s      r   rl   zlayer_sort.<locals>.<listcomp>  s+    
G
G
GVAYY
G
G1
G
G
G
Gr   )r  r   r   rI   r  r  )hmap	orderingsokeysr  s      @r   
layer_sortr
    s    
 9 X XqDDDDQV\\^^DDDe	UqU1XY66!58					VVE!""Iu@U@UVVV	W	W	W	W
G
G(33
G
G
GGr   r3  c                 ~    t          t                    }| D ]%}||d|                                      |           &|S )z
   Splits a global ordering of Layers into groups based on a slice of
   the spec.  The grouping behavior can be modified by changing the
   length of spec the entries are grouped by.
   N)r   r   r  )orderinglengthgroup_orderingsrn  s       r   layer_groupsr    sJ     !&&? . .rb&k"))"----
r   c                 \   ||t          | d                   x}}t          j        ||z
            }|dk    rft          | |          } t	          t
                    }t          j        | |          D ])\  }}t          t          |          |dz
  |          ||<   *|S t          |           S )z~
    Given a list of key tuples to select, groups them into sensible
    chunks to avoid duplicating indexing operations.
    Nr   r   r  )
r   operator
itemgetterr  r   r   r  r  group_selectr   )selectsr  depthgettergrouped_selectsr'  r   s          r   r  r    s    
 ~%-WQZ( v..Fzzf---%d++%gv66 	H 	HDAq!-d1ggvax!G!GOAG}}r   c                 Z   t          |          }||n|}g }t          |t                    rI|                                D ]3\  }}|t	           | j        di |||z
           |i|||dz
            z  }4n5|D ]2}|                    | | j        di |d         |d         if           3|S )zw
    Takes the output of group_select selecting subgroups iteratively,
    avoiding duplicating select operations.
    Nr   r(  r   )r   rn   r   r   iterative_selectselectr  )	r   r+  r  r  r  r   r'  r   r   s	            r   r  r    s    
 
OOE&EEEEE'4   EMMOO 	> 	>DAq%jcj&P&PJuU{4KQ3O&P&P&0!U1W> > >EE	>  	E 	EALL!ZSZBB:b>1R5*ABBCDDDDLr   c                 4    | j         j        | j        | j        fS )z3
   Gets the spec from any labeled data object.
   )r8   r:   r  ri  r   s    r   get_specr    s     =!9ci! !r   c                     d}dt           j        v rdt           j        v rddlm} t	          | t
          j                  p|duot	          | |j                  S )z@
    Checks whether the supplied data is of DataFrame type.
    Ndask.dataframepandasr   )sysmodulesdask.dataframe	dataframern   r   r   r  dds     r   is_dataframer&    se     
B3;&&8s{+B+B######tR\** >T><jr|<<?r   c                     d}dt           j        v rddlm} t	          | t
          j                  p|duot	          | |j                  S )z=
    Checks whether the supplied data is of Series type.
    Nr  r   )r   r!  r"  r#  rn   r   r   r$  s     r   	is_seriesr(    sY     
B3;&&######tRY'' ;T>9jry99<r   c                 `    d }dt           j        v rdd lm} |d uot	          | |j                  S )Nz
dask.arrayr   )r   r!  r  r  rn   Array)r  r  s     r   r  r    sA    	Bs{""dN9z$99:r   c                 T    dt           j        v rdd l}t          | |j                  S dS )Ncupyr   F)r   r!  r,  rn   rs   )r  r,  s     r   is_cupy_arrayr-    s/    $---5r   c                 h    dt           j        v r#dd l}t          | |j        j        j                  S dS )Nibisr   F)r   r!  r/  rn   exprr  
ColumnExpr)r  r/  s     r   is_ibis_exprr2    s4    $	 :;;;5r   c                    t          | j        | j        | j                  }| j        | j                            d          d         j        k    r1t          t          |           j        t                    s
| j        |d<   |S )N)r  r,  ri  Fr  )r   r  r,  ri  r  rH   objectsrC   rn   r   r   )r  rJ   s     r   get_param_valuesr5  %  st    
$*
$ $ $F
dj((//8@@@4::#X.. 	A*wMr   c                     t          j        |           o&t          t          |           t          j                  }|r&|r$t          | di                               d          S |S )a  Whether the object is a method on a parameterized object.

    Args:
       obj: Object to check
       has_deps (boolean, optional): Check for dependencies
          Whether to also check whether the method has been annotated
          with param.depends

    Returns:
       A boolean value indicating whether the object is a method
       on a Parameterized object and if enabled whether it has any
       dependencies
    _dinfodependencies)r   r  rn   r>  rH   r  r)  r   )r   has_depsr  s      r   is_param_methodr:  .  sk     %c** L 0 5 5u7JKK  > >sHb))--n===r   c                    d}t          | t                    rd | D             } nt          | t                    rt          d | D                       } nt          | t                    rd |                                 D             } n\t          | t
                    rGt          t          | j                  t          | j                  t          | j	                            } dt          j        v r_ddlm} ddlm} t          | |          }t           t#          d	          k    r t$          j                            |           } n ||           } t+          | d
          r |             } nt          | t$          j                  r:t          | j        t$          j                  rt3          | j        | j                  } nt          | t6                    rqt9          | d          ra| j        }d |                    dg           D             }d |                    di                                           D             } | |i |} t          | t                    r|r	t          |  } | S )a  Resolves parameter dependencies on the supplied value

    Resolves parameter values, Parameterized instance methods,
    parameterized functions with dependencies on the supplied value,
    including such parameters embedded in a list, tuple, dictionary, or slice.

    Args:
       value: A value which will be resolved

    Returns:
       A new value where any parameter dependencies have been
       resolved.
    Fc                 ,    g | ]}t          |          S r   resolve_dependent_valuer  s     r   rl   z+resolve_dependent_value.<locals>.<listcomp>S  s!    ;;;(++;;;r   c              3   4   K   | ]}t          |          V  d S r   r=  r  s     r   r   z*resolve_dependent_value.<locals>.<genexpr>U  s+      @@Q-a00@@@@@@r   c                 N    i | ]"\  }}t          |          t          |          #S r   r=  r\  s      r   r]  z+resolve_dependent_value.<locals>.<dictcomp>W  s=     
 
 
GKq!#A&&(?(B(B
 
 
r   panelr   )param_value_if_widget)RangeSliderr   T)r9  r7  c              3   J   K   | ]}t          |j        |j                  V  d S r   r)  ownerrk   ri   ps     r   r   z*resolve_dependent_value.<locals>.<genexpr>p  s0      OOQ((OOOOOOr   r8  c                 J    i | ] \  }}|t          |j        |j                  !S r   rE  )ri   r'  rH  s      r   r]  z+resolve_dependent_value.<locals>.<dictcomp>q  s,    UUU$!Q!WQWaf--UUUr   r   )rn   r   r  r   r   r-  r>  r   r   stepr   r!  panel.dependsrB  panel.widgetsrC  param_versionr
   rH   r  resolve_valuer:  	ParameterrF  r  r)  rk   r	   r  r7  r   )r9  range_widgetrB  rC  depsr   r7   s          r   r>  r>  C  su    L% 
;;U;;;	E5	!	! 
@@%@@@@@	E4	 	  	

 
OT{{}}
 
 
 
E5	!	! 
#EK00#EJ//#EJ//
 
 #+777777------!%557:....'55e<<EE))%00Eut,,, '	E5?	+	+ '
5;H[0\0\ 'UZ00	E<	(	( 'WUH-E-E '|OO$((>22N2NOOOUU$((4:L:L:R:R:T:TUUUt&v&&% L uLr   c                 >    d |                                  D             S )au  Resolves parameter dependencies in the supplied dictionary

    Resolves parameter values, Parameterized instance methods and
    parameterized functions with dependencies in the supplied
    dictionary.

    Args:
       kwargs (dict): A dictionary of keyword arguments

    Returns:
       A new dictionary where any parameter dependencies have been
       resolved.
    c                 4    i | ]\  }}|t          |          S r   r=  r\  s      r   r]  z,resolve_dependent_kwargs.<locals>.<dictcomp>  s'    EEEdaA&q))EEEr   )r   )r7   s    r   resolve_dependent_kwargsrT  x  s!     FEfllnnEEEEr   c              #     K   | j                             d                                          }d |D             }|D ]	}d|_        
	 dV  t	          ||          D ]\  }}||_        dS # t	          ||          D ]\  }}||_        w xY w)zS
    Temporarily set parameters on Parameterized object to
    constant=False.
    existingc                     g | ]	}|j         
S r   )constantrG  s     r   rl   z$disable_constant.<locals>.<listcomp>  s    ,,,,,,r   FN)rH   r4  r   rX  r  )r  rJ   	constantsrH  consts        r   disable_constantr[    s        ((44;;==F,,V,,,I  

fi00 	 	JQAJJ	 	#fi00 	 	JQAJJ	s   A+ +B
c                 (   d}t          | j                                                  }|E	 t          |          }n# t          $ r Y dS w xY wt          |dd          st          ||          }|E|dk    rt          |          j        }||k    rdS |S )z_
    Function to get the first non-auxiliary object
    label attribute from an NdMapping.
    N_auxiliary_componentTr  )r  r  r   r  StopIterationr)  r   r:   )	ndmappingattrri  elsrn  tps         r   get_ndmapping_labelrc    s    
 E
y~$$&&
'
'C
-	cBB 	 	 	44	r1488 	&B%%E - w"XX;;4Ls   < 
A
	A
c                 6    t          | t                    r| n| fS )z& Wraps any non-tuple types in a tuple )rn   r  )	unwrappeds    r   r*  r*    s    #Iu55GIII<Hr   c                     dgddl m} t           |          rui } j        D ]j}t          |t                    r j                            ||          ||<   6 j                            |j        |j        f|j                  ||j        <   kn!fd j	        D             } fd|D             }|rd |
                                D             S |S )a  
    Return a complete dictionary mapping between stream parameter names
    to their applicable renames, excluding parameters listed in
    exclude_params.

    If reverse is True, the mapping is from the renamed strings to the
    original stream parameter names.
    Nrk   r3  Paramsc                     g | ]}|v|	S r   r   )ri   r'  exclude_paramss     r   rl   z'stream_name_mapping.<locals>.<listcomp>  s#    GGG!q/F/FA/F/F/Fr   c                 H    i | ]}|j                             ||          S r   )_renamer   )ri   r'  streams     r   r]  z'stream_name_mapping.<locals>.<dictcomp>  s-    AAA11fn((A..AAAr   c                     i | ]\  }}||	S r   r   r\  s      r   r]  z'stream_name_mapping.<locals>.<dictcomp>  s    00011000r   )r  rh  rn   
parametersr   rl  r   rF  rk   rH   r   )rm  rj  reverserh  mappingrH  filtereds   ``     r   stream_name_mappingrs    s           &&!! 	B" 	P 	PA!S!! P#^//155

"(."4"4agqv5F"O"O		P HGGGv|GGGAAAAAAA 000000r   c                     i }t          | |          }|                                D ]M\  }}||vr9d}|rdnd}t          |                    t	          |          |                    ||||         <   N|S )aA  
    Given a stream and a kwargs dictionary of parameter values, map to
    the corresponding dictionary where the keys are substituted with the
    appropriately renamed string.

    If reverse, the output will be a dictionary using the original
    parameter names given a dictionary using the renamed equivalents.
    )rp  z6Could not map key {key} {direction} renamed equivalentfromto)r   	direction)rs  r   r  formatr   )	rm  r7   rp  mapped_kwargsrq  r'  r   r6   rw  s	            r   rename_stream_kwargsrz    s     M!&':::G||~~ & &!GJC")3tI3::$q''Y:GGHHH$%gaj!!r   c                    ddgddl m} i }| D ]R}|j        s2t          |j        t
                    rt          |j                  ||<   ;t          |j                  ||<   S|ri g }}g }| D ]w}t          ||          r||         D ][}	|	|v rP|                    |	           ||	         |vr|                    ||	                    |                    |           V|||	<   \xt          |          }|rEd	                    d |dd         D                       }
t          d	|
 d
|d          d|          fd|                                D             S )z
    Given a list of streams, return a flat list of parameter name,
    excluding those listed in the exclude list.

    If no_duplicates is enabled, a KeyError will be raised if there are
    parameter name clashes across the streams.
    Nrk   _memoize_keyr3  rg  r   c                 ,    g | ]}t          |          S r   r   )ri   r  s     r   rl   z%stream_parameters.<locals>.<listcomp>  s    !F!F!Fa$q''!F!F!Fr   r(  zThe supplied stream objects z and z$ clash on the following parameters: c                 &    g | ]}|D ]}|v|	S r   r   )ri   r  rk   excludes      r   rl   z%stream_parameters.<locals>.<listcomp>  s>     $ $ $U $ $7"" """"r   )r  rh  contentsrn   hashkeyr   r   r  r  r  r   r   )r  no_duplicatesr  rh  param_groupsr   r  clashesclash_streamsr  clashings     `        r   r  r    s    >*      L / /z 	/jD99 	/"19ooLOO"1:..LOO OBg 
	  
	 A!V$$ !!_    99NN1%%%Awm33%,,T!W555!((++++DGG  // 	Oyy!F!F="3E!F!F!FGGH N8 N N-XZJ[ N NBIN N O O O$ $ $ $l1133 $ $ $ $r   c                 @    t          | |          }fd|D             S )zn
    Return a list of stream parameters that have not been associated
    with any of the key dimensions.
    c                     g | ]}|v|	S r   r   )ri   rk   r  s     r   rl   z*dimensionless_contents.<locals>.<listcomp>  s#    888Td%&7&7D&7&7&7r   r  )r  r  r  r   s    `  r   dimensionless_contentsr    s.    
 g}55E8888U8888r   c                 @    t          | |          fd|D             S )zY
    Return a list of dimensions that have not been associated with
    any streams.
    c                     g | ]}|v|	S r   r   )ri   r  rJ   s     r   rl   z&unbound_dimensions.<locals>.<listcomp>  s    000!Ar   r  )r  r  r  rJ   s      @r   unbound_dimensionsr    s.    
 w66F0000u0000r   c                 d  
 d |D             }d |D             }g }t          t          |                     D ]i\  
}|M
t                    k     r:
fd|D             }t          |          dk    r|d         \  }}	|	j        |         }|                    |           jt          |          S )zL
    Fills in tuple keys with dimensioned stream values as appropriate.
    c                 D    g | ]}|j                                         |fS r   )r  r   ri   r   s     r   rl   z&wrap_tuple_streams.<locals>.<listcomp>"  s)    <<<qQZ__&&*<<<r   c                 &    g | ]\  }}|D ]}||fS r   r   )ri   r  r   rk   s       r   rl   z&wrap_tuple_streams.<locals>.<listcomp>#  s-    HHH:E1%HH$d1XHHHHr   Nc                 @    g | ]\  }}|         j         k    ||fS r   r  )ri   rk   r   r  poss      r   rl   z&wrap_tuple_streams.<locals>.<listcomp>'  s1    OOOHT!uSz9N9NQx9N9N9Nr   r   r   )r  r*  r   r  r  r  )re  r  r  r  pairssubstitutedrn  matchesrk   rm  r  s    `        @r   wrap_tuple_streamsr    s     =<G<<<LHHHHHEKJy1122  B:#E

**OOOOOOOOG7||q  !(v_T*2r   c                    t          |           t          fdt          |          D              \  }}t          j        | fd|D             }|t          |          dk    rd |D             nt          |          fS )z?
    Drop any dimensioned streams from the keys and kdims.
    c                 &    g | ]\  }}|v	||fS r   r   )ri   indr  r  s      r   rl   z drop_streams.<locals>.<listcomp>4  s5     5 5 5ysDm33 T{333r   c              3   .   K   | ]} |          V  d S r   r   )ri   r'  r   s     r   r   zdrop_streams.<locals>.<genexpr>7  s+      !!qCCFF!!!!!!r   r   c                 ,    g | ]}t          |          S r   )r*  r&  s     r   rl   z drop_streams.<locals>.<listcomp>8  s    ///Q:a==///r   )r  r  r  r  r  r   r   )r  r  r   r^  r  r   r  s        @@r   drop_streamsr  /  s     &g..M 5 5 5 5Ie4D4D 5 5 5 6JD$

t
$C!!!!D!!!D3t99>>//$////tDzzRRr   c                       fd|D             t          j         t          fd j                                        D                       S )Nc                 :    g | ]}                     |          S r   get_dimension_indexri   r  r_  s     r   rl   z#get_unique_keys.<locals>.<listcomp><  s'    EEE3I))#..EEEr   c              3   r   K   | ]1}t                    d k    r |          n|d                  fV  2dS )r   r   NrP  )ri   r   r  r^  s     r   r   z"get_unique_keys.<locals>.<genexpr>>  s[       = =" +.d))a--66#;;;c$q'l_ = = = = = =r   )r  r  r  r  r   )r_  r+  r  r^  s   ` @@r   get_unique_keysr  ;  sv    EEEE*EEED $'F = = = = =&/n&9&9&;&;= = = = = =r   c              #      K   |                                  D ]G\  }}|j        d         } ||          }t          |d          r||fV  4t          |          |fV  Hd S )Nr   r  )iterrowsr   r  r*  )r  r  r'  r   r   r   s         r   unpack_groupr  B  s         ) )1hqkfQii3   	)*c??C((((() )r   c                 T    | r%| d                                          | dd         z   S | S )z3
    Capitalizes the first letter of a string.
    r   r   N)r   )r  s    r   r  r  L  s2      ay  6!"":--r   c                    t           t          g}t          | t                    rZ| \  }} | j        rCt          |          dk    r| j        |d         k    r|dd         }n<|dd         | j        fz   }n(|dd         }n| j        r| j        | j        fn| j        f}t          d t          ||          D                       S )z
    Gets a path from an Labelled object or from a tuple of an existing
    path and a labelled object. The path strings are sanitized and
    capitalized.
    r   Nr3  c              3   L   K   | ]\  }}t           ||                    V   d S r   r  )ri   rH  r  s      r   r   zget_path.<locals>.<genexpr>h  s6      HHw2BBqEE""HHHHHHr   )r  r  rn   r  ri  r   r  r  )r  
sanitizersr  s      r   get_pathr  V  s     "?3J$ 
I
d: 	4yy1}}tAw!6!6BQBxBQBx4:-/8DD+/:H
DJ''DJ=HH#dJ2G2GHHHHHHr   c                     d}t           fd|D                       rj|          }| xx         dz  cc<   |st                     dk    s|r dd          nd} t          |          fz    t           fd|D                       jt                     dk    r' t          |                     d                    fz     |vrd| <    S )z_
    Given a path, a list of existing paths and counts for each of the
    existing paths.
    Fc              3   z   K   | ]5}t          d t          |          d z             D ]}|d|         k    V  6dS r$  )rg  r   )ri   r  r\   r  s      r   r   z#make_path_unique.<locals>.<genexpr>q  sP      HHU1c!ffQh5G5GHHdaemHHHHHHHr   r   Nr(  T)r&   r   r  r   )r  countsru   addedr   s   `    r   make_path_uniquer  k  s   
 E
HHHHVHHH
H
H -tt 	D		A%9DDE|E**,, HHHHVHHH
H
H - 4yyA~~|FJJtQ$7$788::6tKr   c                       e Zd ZdZ ej        dd          Z	 d	dZej        j	        	 d	d            Z
ej        j	        	 d	d            ZdS )
ndmapping_groupbyzl
    Apply a groupby operation to an NdMapping, using pandas to improve
    performance (if available).
    Fz!Whether to apply a sorted groupbyrB   c                 (     | j         ||||fd|i|S )NrZ  )groupby_pandas)r5   r_  r+  container_type
group_typerZ  r7   s          r   rK   zndmapping_groupby.__call__  s7    "t"9j.!8 8(,8068 8 	8r   c           	         dv rfdd         D             }nfdj         D             }d j         D             }fd|D             }	|	rt          j        |	 nd t          j                                                            |          }
t          j        t          t          t                                                              |
          }t          t          t                    |	          fd
|it          j                    5  t          j        dt"          d           fd|                    d D             |          D             }d d d            n# 1 swxY w Y   |r1t          t'                              t)          |fd          } |||          S )Nr  c                 :    g | ]}                     |          S r   )get_dimension)ri   r  r_  s     r   rl   z4ndmapping_groupby.groupby_pandas.<locals>.<listcomp>  s'    IIIAY,,Q//IIIr   c                     g | ]}|v|	S r   r   ri   r  r+  s     r   rl   z4ndmapping_groupby.groupby_pandas.<locals>.<listcomp>  s#    MMMSs*7L7LS7L7L7Lr   c                     g | ]	}|j         
S r   r  r  s     r   rl   z4ndmapping_groupby.groupby_pandas.<locals>.<listcomp>  s    444qAF444r   c                 :    g | ]}                     |          S r   r  r  s     r   rl   z4ndmapping_groupby.groupby_pandas.<locals>.<listcomp>  s'    DDDs	--c22DDDr   c                     dS rG   r   r  s    r   r   z2ndmapping_groupby.groupby_pandas.<locals>.<lambda>  s    2 r   )r   rf   r  rZ  r  z)Creating a Groupby object with a length-1)r|  messagec           
   3      K   | ]:\  }}t          |           t          t          |                    fi fV  ;d S r   )r*  r   r  )ri   r'  r  r  r  r7   s      r   r   z3ndmapping_groupby.groupby_pandas.<locals>.<genexpr>  ss       _ _ 5 "!}}jjl5&6Q6Q1R1R&]&]V\&]&]^ _ _ _ _ _ _r   c                     g | ]	}|j         
S r   r  r  s     r   rl   z4ndmapping_groupby.groupby_pandas.<locals>.<listcomp>  s    5Q5Q5Qaf5Q5Q5Qr   )r  rZ  c                 :                         | d                   S )Nr   rf   )r  r  s    r   r   z2ndmapping_groupby.groupby_pandas.<locals>.<lambda>  s    '--!2E2E r   r  )r  rZ  )r  r  r  r   r   from_tuplesr   r   r   mapr*  r   r   r5  r  r  r  FutureWarningr  r  r  )r_  r_  r+  r  r  rZ  r7   idimsall_dimsr^  multi_indexdfr   r  r  s    `` ` `      @@r   r  z ndmapping_groupby.groupby_pandas  sh    fIIIIIIIEEMMMMIOMMME44IO444DDDDeDDD/3E$d++m//	0@0@/QQ\$s:y/?/?/A/ABBCC;WWW d+I66eDDDZZ4ZSYZZ$&& 	_ 	_ #=:e   _ _ _ _ _ _$&JJ5Q5Qj5Q5Q5QX\J$]$]_ _ _F	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_ 	_  	G?9jAABBGF(E(E(E(EFFFF~fJTBBBBs   AE66E:=E:c                    
 fd|j         D             
d D             }t          |          }t          t          |                    }
fdt	          |||          D             }	 ||	          S )Nc                     g | ]}|v|	S r   r   r  s     r   rl   z4ndmapping_groupby.groupby_python.<locals>.<listcomp>  s#    III3j3H3H3H3H3Hr   c                     g | ]	}|j         
S r   r  )ri   r  s     r   rl   z4ndmapping_groupby.groupby_python.<locals>.<listcomp>  s    444#SX444r   c           	      |    g | ]8\  }}| t          |d           r|                              nd|fgfi f9S )r  r   )r  reindex)ri   r'  r   r  r  r7   s      r   rl   z4ndmapping_groupby.groupby_python.<locals>.<listcomp>  s~     O O Oa jjga6I6I #1!))E"2"2"2)+Qy= =5;= = > O O Or   r  )r  r  r  r   r  )r_  r_  r+  r  r  rZ  r7   	dim_namesr  r   r  s     ` ` `   @r   groupby_pythonz ndmapping_groupby.groupby_python  s     JIII	III44444	!)Z88tG}}--O O O O O O.y)WMMO O O ~fJ7777r   NF)r:   r;   r<   r=   rH   rL   rZ  rK   r  r  r  r  r   r   r   r  r    s         
 5=,OPPPD #(8 8 8 8
 #(-C C C $#C> #(-	8 	8 	8 $#	8 	8 	8r   r  c                     t          j        t          j        |   } |rt          fd| D                       S t          fd| D                       S )a  
    Efficient cartesian product of a list of 1D arrays returning the
    expanded array views for each dimensions. By default arrays are
    flattened, which may be controlled with the flat flag. The array
    views can be turned into regular arrays with the copy flag.
    c              3   R   K   | ]!}r|                                 n|j        V  "d S r   )flattenr{   ri   r.  copys     r   r   z$cartesian_product.<locals>.<genexpr>  s6      KKSd8S[[]]]KKKKKKr   c              3   H   K   | ]}r|                                 n|V  d S r   )r  r  s     r   r   z$cartesian_product.<locals>.<genexpr>  s4      ??t,??????r   )rr   broadcast_arraysix_r  )arraysr{   r  s     `r   cartesian_productr    sg      "&&/2F LKKKKFKKKKKK??????????r   c                    d | D             }t          j        |          }||k    rt          d||fz            g }t          dt	          |                     ddd         D ]E}t          j        || d                   }|                    ||z             ||d         |z  z  }F|                    |           t          d t          | |          D                       S )a	  
    Allows efficiently indexing into a cartesian product without
    expanding it. The values should be defined as a list of iterables
    making up the cartesian product and a linear index, returning
    the cross product of the values at the supplied index.
    c                 ,    g | ]}t          |          S r   rP  r  s     r   rl   zcross_index.<locals>.<listcomp>  s    &&&!s1vv&&&r   z3Index %d out of bounds for cross-product of size %dr   Nr(  c              3   ,   K   | ]\  }}||         V  d S r   r   )ri   r   r\   s      r   r   zcross_index.<locals>.<genexpr>  s*      77$!Q1777777r   )rr   r(   
IndexErrorrg  r   r  r  r  )r   rg   lengthsr  r  r\   rH  s          r   cross_indexr    s     '&v&&&GWWFN!6?+ , , 	,G1c&kk""44R4( ! !GGQBCCL!!uax   q NN577#fg"6"6777777r   c                     d                     d | D                       }t          j        t          | d                   |          }t	          |           D ]\  }}||d| <   |                                S )z^
    Returns the indices of the lexicographical sorting
    order of the supplied arrays.
    r  c              3   .   K   | ]}|j         j        V  d S r   )r!  r   )ri   r  s     r   r   zarglexsort.<locals>.<genexpr>  s&      ::%eko::::::r   r   r  r  )r  rr   emptyr   r  argsort)r  dtypesrecarrayr\   r  s        r   
arglexsortr    s    
 XX::6:::::FxF1If555Hf%% " "5!Qr   c                     g }| j         D ]H}t          |g          }d | j        D             t          |          z  r|                    |           I|S )z
    Given a DynamicMap return all streams that have any dimensioned
    parameters, i.e. parameters also listed in the key dimensions.
    c                 ,    h | ]}t          |          S r   )r   r&  s     r   r   z&dimensioned_streams.<locals>.<setcomp>  s    '''qCFF'''r   )r  r  r  ro   r  )dmapdimensionedrm  r  s       r   dimensioned_streamsr    si    
 K, ' ')6(33''DJ'''#m*<*<< 	'v&&&r   c                 f     fd j         D             }|rV j                             d          } j                             |d         dd          }|t	          j        |          z  S  fd j         D             }                               }t          |d          |         j        S )z
    Expand the coordinates along a dimension of the gridded
    dataset into an ND-array matching the dimensionality of
    the dataset.
    c                 \    g | ](}|uj                             |          !|j        )S r   )	interface	irregularrk   )ri   r  datasetr  s     r   rl   z&expand_grid_coords.<locals>.<listcomp>  sE     N N NASLLW%6%@%@!%L%LL  LLr   Tr   Fc                 R    g | ]#}j                             |j        d           $S r  )r  coordsrk   )ri   r  r  s     r   rl   z&expand_grid_coords.<locals>.<listcomp>  s@     * * * #**7AFDAA * * *r   )r{   )	r  r  r  r   rr   	ones_liker  r  T)r  r  r  r  exampler  idxs   ``     r   expand_grid_coordsr    s    N N N N N N N NI <!((#t<<#**7IaL$NNr|G,,,,* * * *"=* * *))#.. e444S9;;r   c                     | t          j        d          z
  t          j        dd          z  }t          j        dddddd          t          j        |          z   S )z@
    Safely converts NumPy datetime64 to a datetime object.
    z1970-01-01T00:00:00r   r     r   )seconds)rr   r  r  r   r   	timedelta)dt64tss     r   
dt64_to_dtr    sV     455
539O9O	OB;tAa!A&&b)A)A)AAAr   c                 N    	 t          j        |           S # t          $ r Y dS w xY w)z8
    Checks whether value is NaN on arbitrary types
    F)rr   isnanr   r  s    r   r%  r%    s7    x{{   uus    
$$usc                 L   t          |           st          j        t          j        |dfS |                                 |                                 }}d}t          |           dk    r| d         | d         k    rd}|st          j                    5  t          j        dd           t          ||t          |           dz
            }t          j	        d          5  t          |t          j        j                  }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |dt          j        fv r|}|dk    rt          d	          d
|z  }t!          |t"                    r/t          j        t'          t          |                    |          }||z
  ||z   ||fS )z
    Computes a bounding range and density from a number of samples
    assumed to be evenly spaced. Density is rounded to machine precision
    using significant digits reported by sys.float_info.dig.
    Fr   r   Tr  z;invalid value encountered in (double_scalars|scalar divide))rR  NzBCould not determine Image density, ensure it has a non-zero range.g      ?)r   rr   r  r$   r#   r  r  r  compute_densityerrstateroundr   
float_infodiginfr   rn   r  r  r   )r  density	time_unitlowhighinvertfull_precision_densityhalfds           r   bound_ranger    s%    t99 /vrvw..

DHHJJCF
4yy1}}a47** -$&& 	L 	L#H.lmmm%4S$D		!%L%L"(+++ L L 68JKKL L L L L L L L L L L L L L L	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L
 q"&k!!,G!||]^^^KE#~&& =s5<<00)<<u9d5j'611s7   AD D<DD	DD	DD#&D#h㈵>c                    t          j        |           }t          |          dk     p[t          |                                |                                z
            t          |                                |z            k     S )z
    Validates regular sampling of a 1D array ensuring that the difference
    in sampling steps is at most rtol times the smallest sampling step.
    Returns a boolean indicating whether the sampling is regular.
    r   )rr   diffr   absr$   r#   )r   rtoldiffss      r   validate_regular_samplingr  6  s]     GFOOEJJNSs599;;uyy{{#:;;c%))++dBR>S>SSSr   c                    t          | t                    rt          |           } t          |t                    rt          |          }|| z
  }t          |t                    rt          |t          j                  r't	          j        ||                                          }dt	          j        d|                                                                          z  }||                                |z  z  S ||z  S )z
    Computes a grid density given the edges and number of samples.
    Handles datetime grids correctly by computing timedeltas and
    computing a density for the given time_unit.
          ?r   )rn   r   r  r  rr   r  tolisttotal_seconds)r   r>  r  r  r  tscales         r   r  r  @  s     %3uU||u#s-5::Su9D$(( dBN++ 	<>$	2299;;DBN1i007799GGIII**,,V345d{r   c                 &   dt          | |||          z  }t          | t          j                  r|                                 } t          j        t          t          |                    |          }| |dz  z   t          j	        |          |z  z   S )z[
    Computes a date range given a start date, end date and the number
    of samples.
    r  r4  )
r  rn   r   r)  r(  rr   r  r   r	  arange)r   r>  r  r  rJ  s        r   
date_ranger#  R  s    
 uc69===D%&& &##%%>#eDkk**I66Db=6**4///r   c                 N    t          j        |                                           S )zI
    Parses dates specified as string or integer or pandas Timestamp
    )r   to_datetimer(  )dates    r   parse_datetimer'  ^  s      >$--///r   c                 :   t          | t                    st          |           rt          |           } t          | t                    rt          | j        t                    st          | j                  r't	          t          | j                  | j                  } t          | j        t                    st          | j                  r't	          | j        t          | j                            } t          | t          t          f          rd | D             } | S )z5
    Parses string selection specs as datetimes.
    c                 Z    g | ](}t          |t                    rt          |          n|)S r   )rn   r   r'  r  s     r   rl   z,parse_datetime_selection.<locals>.<listcomp>q  s4    KKK!Jq#$6$6=~a   AKKKr   )	rn   r   r  r'  r-  r   r   ro   r   )sels    r   parse_datetime_selectionr+  e  s     #s "z# "S!!#u =ci%% 	=CI)>)> 	=sy1138<<Cch$$ 	=
38(<(< 	=	>#(#;#;<<C#T{## LKKsKKKJr   c                    t          | t          j                  r|                                 } t          | t          j                  rL	 |                                 } n6# t          $ r) t          j        | 	                                          } Y nw xY wt          | t                    rt          | |          S t          | t          j                  rBt          | t          j                  s(t          j        |                                 dd          } t          | t          j                  r	 t          j        | d          } t          j        d|          t          j        dd          z  }t#          |                                 |z            S # t          $ r |                                 } Y nw xY w|dk    rd}n<dt          j        d|                                                                          z  }| j        t          j        ddd          }n't          j        dddt          j        j                  }t#          | |z
                                  |z            S )	zM
    Converts a datetime type to an integer with the supplied time unit.
    NrK  nsr   g    eAr  r  )tzinfo)rn   r   r&  r'  r)  r(  r   rr   r  to_pydatetimer   cftime_to_timestampr   r&  r   	timetupler  r   r  r  r.  timezoneutc)r9  r  r   _epochs       r   	dt_to_intr5  u  s,    %## %""$$%&& 9	9''))EE 	9 	9 	9M%"5"5"7"788EEE	9%&& 5"5)444 %!! 4*UBK*H*H 4U__..rr23 %'' #	#M%..EnQ	222>!T3J3JJFu||~~./// 	# 	# 	#LLNNEEE	# DBN1i007799GGIII|T1a((T1a@@@--//&8999s%   
A 0BB1A#F F65F6c                     ddl }|dk    rd}n+t          j        dd          t          j        d|          z  } |j        | dd          |z  S )a  Converts cftime to timestamp since epoch in milliseconds

    Non-standard calendars (e.g. Julian or no leap calendars)
    are converted to standard Gregorian calendar. This can cause
    extra space to be added for dates that don't exist in the original
    calendar. In order to handle these dates correctly a custom bokeh
    model with support for other calendars would have to be defined.

    Args:
        date: cftime datetime object (or array)

    Returns:
        time_unit since 1970-01-01 00:00:00
    r   Nr  r   z&microseconds since 1970-01-01 00:00:00r   )calendar)cftimerr   r  date2num)r&  r  r8  r   s       r   r0  r0    sl     MMMD.D))".I*F*FF6?4 H$.0 0 0067 7r   c                     	 |                                 }nX# t          $ rK |                    t                    }|                     t                    } |                                 }Y nw xY w|t	          j        ||         |                    S )zd
    Given a set of values returns the indices of each of those values
    in the source array.
    )r  r   r7  r   rr   searchsorted)r   sourceorig_indicess      r   search_indicesr>    s    
(~~'' ( ( ( s##s##~~''( |(<fEEFFs    AA,+A,c                 B   t          j        |           } | j        j        dk    r|                     d          } | dd         | dd         z   dz  }d| d         z  |d         z
  d| d         z  |d         z
  f}t          j        |dd         ||dd         g          S )	z
    Computes edges as midpoints of the bin centers.  The first and
    last boundaries are equidistant from the first and last midpoints
    respectively.
    r\   r  Nr(  r   r4  r3  r   )rr   r  r!  r"  r7  r  )r  	midpoints
boundariess      r   compute_edgesrB    s     JuE{3S!!sseABBi',IE!H*y|+QuRy[9R=-HIJ>:bqb>9joFGGGr   c                     t          | t                    r| \  }}n| }|                    dd          }d|v r|d         }|d| dz  }|S )z+
    Converts a MIME bundle into HTML.
    z	text/htmlr   zapplication/javascriptz'
<script type="application/javascript">z	</script>)rn   r  r   )bundler  metadatahtmljss        r   mimebundle_to_htmlrH    sj     &%   hh88K$$D4''*+H2HHHHKr   c                     t          |           }t          |t          j                  rt	          |           S t          |t          j                  rt          |           S | S )z;
    Converts a NumPy scalar to a regular python type.
    )r   r   rr   float64r  int_r   )scalarscalar_types     r   numpy_scalar_to_pythonrN    sT     v,,K+rz** V}}	K	)	) 6{{Mr   c           
         	 t                     dk    rdS g }g }|D ]h\  }		d          d         k    r |                    |	dd         f           8t          d 	 fD                       r=t           	fdt	          t           d                             D                       }nt           d                   rt          	d                   rt           d         t          j                  rt           d                   n d         }t          	d         t          j                  rt          	d                   n	d         }t          ||z
             }nd}|                    ||	d         f           jt          |          dk    r|d         d         S |r|dz   }t           dd         ||          S |dk    s|sdS t          |d           d         d         S )zn
    Recursively iterates over type, group, label and overlay key,
    finding the closest matching spec.
    r   Nr   c              3   L   K   | ]}t          |d          t                    V   dS r   NrV  r  s     r   r   z closest_match.<locals>.<genexpr>  s0      @@Q:adC((@@@@@@r   c              3   n   K   | ]/}d                               d          d|                   +|V  0dS rQ  )rp  )ri   r\   r  r  s     r   r   z closest_match.<locals>.<genexpr>  sb       #H #H&+Ah&9&9$q'"1"+&F&F#H1 #H #H #H #H #H #Hr   c                     | d          S r   r   r  s    r   r   zclosest_match.<locals>.<lambda>	  s    AaD5 r   r  )r   r  r%   r#   rg  r5  rn   rr   r  r  r  closest_matchr  )
r  specsr  	new_specsmatch_lengthsr\   match_lengthmr   r  s
   `        @r   rT  rT    s   
 5zzQtIM = =47eAhaabb]++++@@4-@@@@@ !" #H #H #H #H #HeCaMM.B.B #H #H #H  H  H58$$ !47);); !&0q28&D&DRDqNNN%PQ(%/Q%B%BODaMMMQ #AaCy   !\47!;<<<<
9~~|A	 @aU122Y	5999	!=tm999!<Q??r   c                     t          j                    5  t          j        ddt                     |                     d          cddd           S # 1 swxY w Y   dS )a  
    Convert a numpy array  to `int64`. Suppress the following warning
    emitted by Numpy, which as of 12/2021 has been extensively discussed
    (https://github.com/pandas-dev/pandas/issues/22384)
    and whose fate (possible revert) has not yet been settled:

        FutureWarning: casting datetime64[ns] values to int64 with .astype(...)
        is deprecated and will raise in a future version. Use .view(...) instead.

    r  zcasting datetime64)actionr  r|  int64N)r  r  r  r  r7  )r  s    r   cast_array_to_int64r]  	  s     
	 	"	" % %("	
 	
 	
 	

 ||G$$% % % % % % % % % % % % % % % % % %s   1AAAc              #      K   | D ]It          fdt          t          t          fD                       rt	                    E d{V  EV  JdS )a-  
    Flatten an arbitrarily nested sequence.

    Inspired by: pd.core.common.flatten

    Parameters
    ----------
    line : sequence
        The sequence to flatten

    Notes
    -----
    This only flattens list, tuple, and dict sequences.

    Returns
    -------
    flattened : generator
    c              3   8   K   | ]}t          |          V  d S r   )rn   )ri   rb  r  s     r   r   zflatten.<locals>.<genexpr>;	  s-      EE2z'2&&EEEEEEr   N)r&   r   r  r   r  )liner  s    @r   r  r  &	  s|      (   EEEE$t1DEEEEE 	w''''''''''MMMM	 r   r  r  r   r   )r3  r9   )TN)TF)r  )r  )r   )builtinsr   r   rt   r   r  r   r  r  r   r  r   r   r  r{  r  collectionsr   r   
contextlibr   	functoolsr   	threadingr   r   r	   numpyrr   r  r   rH   packaging.versionr
   r   
basestringr   longunicodecmp
attrgetterr  r  rg  r  generator_typesr  r  rM  r  r&  r  r  r  r  rs   r  r  anonymous_dimension_labeldisallow_refsr   rw   r|   r   r   r  pandas.core.dtypes.dtypesr   r   pandas.core.dtypes.genericr   r   r   pandas.types.dtypespandas.types.dtypes.genericr)  r&  r  	Timedeltar  r   pandas.core.arrays.maskedr   r   rQ  mainwarningr8  r   ImportError_STANDARD_CALENDARSr"   r#   r$   r%   r&   nansumr'   nanmeanr(   nanprodr)   nanstdr*   nanvarr+   	nanmedianr
  r	  r,   
nancumprodr-   	nancumsum_PANDAS_FUNC_LOOKUPr/   r   rA   configr^   JSONEncoderr`   r   r   r   r   r   r   r  r  r   r5  r:  r>  rC  rE  instancesanitize_identifierr  r  dimension_sanitizerr  r  r  r  r  r  r  r  r  r  r  r0  rB  rI  ra  rl  r  r  r  r  r  r  r*  r  r  r5  r  r  r  r  r  r  r  r  r
  r  r  r  r  r&  r(  r  r-  r2  r5  r:  r>  rT  r[  rc  r*  rs  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r  r  r  r#  r'  r+  r5  r0  r>  rB  rH  rN  rT  r]  r  r   r   r   <module>r     s                   



        / / / / / / / / % % % % % %       # # # # # # # #                % % % % % % 


"x"7++u23'')**-bgrw?>2<1:- )69L9L)L)Lu%%RT *Y @
A
A  ((S))))TTTTTT	
 	
 	
 	
 	
 	
 	
 	
 	
 
778,,	,	,TTTTTTGGGGGGGGG	''(++	+	+AAAAAAGGGGGGGGG;;;;;;HHHHHHHH\+>	J l_#&;;N%(>>O%M(BBO))))@@@@@@)->,@@&&======') S S S	J NPQR S S S S S S S SSMMMO%Ll"NN   LLLFFF L%L% L% FE	
 FE FE Iu GV J GV J FE Iu FE Iu  Ix!" L(#$ FEIuFEIuJ	M9IxL(3  :( ( ( ( (9 ( ( () ) ) ) )U( ) ) )V 
8 8 8
B B B B B4# B B BJ  2   - - -BA A A A Av A A AJ  ' ' '"_ "_ "_J?2 ?2 ?2D! ! !23 3 3 3@    
 
 
QQ QQ QQ QQ QQU8 QQ QQ QQf -5577  )1133(1133,555GG N N N       $ u%%**400  $& & &R	1 	1 	1         40  0  0  0 f   <   (% % % %P   *  	 	 	  - - -1 1 18  "U U U U&I I I41 1 1.	 	 	1 1 1   "" " " " "+ " " "&2C 2C 2Cj( ( ($F F F% % %H H H	 	 	 	   $   $! ! !? ? ?< < <; ; ;         *2 2 2jF F F"      *I I I
   6   (&$ &$ &$ &$R9 9 9 91 1 1 1  "	S 	S 	S= = =) ) )  I I I*  *78 78 78 78 783 78 78 78t
@ 
@ 
@ 
@8 8 8*	 	 	
 
 
< < <&B B B  2 2 2 28T T T T   $	0 	0 	0 	00 0 0   %: %: %: %:P7 7 7 70G G G"H H H  	 	 	 @  @  @  @F% % %(    s+   "CG& &H+"HHH- -H76H7