o
    MhY&                     @   sV   d d Z dd Zdd Zdd Zdd	 ZdddZdd Zdd Zdd Zdd Z	dS )c                 C   s(   t | dkr
tdtt| t |  S )N    zx must have positive length)len
ValueErrorfloatsumx r   W/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/plotly/shapeannotation.py_mean   s   r
   c                 C   s   t t| dd dd d S )Nc                 S      | d S N   r   tr   r   r	   <lambda>       z_argmin.<locals>.<lambda>)keyr   sorted	enumerater   r   r   r	   _argmin
   s   r   c                 C   s   t t| dd ddd d S )Nc                 S   r   r   r   r   r   r   r	   r      r   z_argmax.<locals>.<lambda>T)r   reverser   r   r   r   r   r	   _argmax   s   r   c                 C   s   t | |||ddS )zDefault annotation parametersF)xanchoryanchorr   y	showarrow)dict)r   r   r   r   r   r   r	   _df_anno   s   r   c                 C   s   d| v sd| v s|  d | S )Ninsideoutside)add)posr   r   r	   _add_inside_to_position   s   
r#   Fc                 C   s2   | d u rd} | }t | d} |rt| } | |fS )Nz	top right )setsplitr#   )positionprepend_insidepos_strr   r   r	   _prepare_position   s   r*   c                 C   s  |d }|d }|d }|d }||g}||g}d}	d}
d}d}d	}d
}t |}t|}t|}t|}t|}t |}t|}t|}t|}t|}t|\}}| dkr|tddgkrgt|	|
|| |S |tddgkrxt||
|| |S |tdgkrt|||| |S |td	dgkrt|	||| |S |td	dgkrt|||| |S |td	gkrt||
|| |S |tdgkrt|	|||S |tdgkrt||||S n| dkrb|tddgkrt||||| S |tddgkrt|	|||| S |tdgkrt||||S |td	dgkrt||
||| S |td	dgkr1t|	|
||| S |td	gkr@t||
||S |tdgkrQt|	|||| S |tdgkrbt||||| S td|f )Nx0x1y0y1righttopleftcenterbottommiddlevlinehlinez Invalid annotation position "%s")	maxminr
   r   r   r*   r%   r   r   )
shape_type
shape_argsr'   r+   r,   r-   r.   XYRTLCBMaYiYeYaaYaiYaXiXeXaaXaiXr)   r   r   r	   annotation_params_for_line'   sv   
rM   c                 C   s  |d }|d }|d }|d }t |dd\}}|tg dkr/tdd	t||gt||gS |tg d
krFtdd	t||gt||gS |tdd	gkr]tdd	t||gt||gS |tg dkrttddt||gt||gS |tg dkrtddt||gt||gS |tddgkrtddt||gt||gS |tddgkrtddt||gt||gS |tddgkrtddt||gt||gS |tdgkrtddt||gt||gS |tg dkr
t| dkrdnd| dkrdnd	t||gt||gS |tg dkr0t| dkrdnd| dkr#dnd	t||gt||gS |tdd	gkrHtddt||gt||gS |tg dkrnt| dkrYdnd| dkrad	ndt||gt||gS |tg dkrt| dkrdnd| dkrd	ndt||gt||gS |tddgkrtdd	t||gt||gS |tddgkrtddt||gt||gS |tddgkrtddt||gt||gS td|f )Nr+   r,   r-   r.   T)r(   )r   r0   r1   r1   r0   )r   r0   r/   r/   r   r2   )r   r3   r1   r3   )r   r3   r/   r4   )r    r0   r1   vrecthrect)r    r0   r/   r    )r    r3   r1   )r    r3   r/   zInvalid annotation position %s)r*   r%   r   r8   r7   r
   r   )r9   r:   r'   r+   r,   r-   r.   r)   r   r   r	   annotation_params_for_recth   sx   







rP   c           
         s   d t  }tt fdd| }| du rt |dkrdS | du r&t } |D ]}|dkr/q(||d }|| | |< q(d}d| v rH|d }|drTt|||}	n|dr_t|||}	|	 D ]}|| vso| | du ru|	| | |< qc| S )	a8  
    annotation: a go.layout.Annotation object, a dict describing an annotation, or None
    shape_type: one of 'vline', 'hline', 'vrect', 'hrect' and determines how the
                x, y, xanchor, and yanchor values are set.
    shape_args: the parameters used to draw the shape, which are used to place the annotation
    kwargs:     a dictionary that was the kwargs of a
                _process_multiple_axis_spanning_shapes spanning shapes call. Items in this
                dict whose keys start with 'annotation_' will be extracted and the keys with
                the 'annotation_' part stripped off will be used to assign properties of the
                new annotation.

    Property precedence:
    The annotation's x, y, xanchor, and yanchor properties are set based on the
    shape_type argument. Each property already specified in the annotation or
    through kwargs will be left as is (not replaced by the value computed using
    shape_type). Note that the xref and yref properties will in general get
    overwritten if the result of this function is passed to an add_annotation
    called with the row and col parameters specified.

    Returns an annotation populated with fields based on the
    annotation_position, annotation_ prefixed kwargs or the original annotation
    passed in to this function.
    annotation_c                    s
   |   S )N)
startswith)kprefixr   r	   r      s   
 z0axis_spanning_shape_annotation.<locals>.<lambda>Nr   annotation_positionlinerect)r   listfilterkeysr   endswithrM   rP   )

annotationr9   r:   kwargs
len_prefixannotation_keysrS   subkrV   
shape_dictr   rT   r	   axis_spanning_shape_annotation   s8   

rc   c                 C   sF   t  }t  }|  D ]}||r| | ||< q
| | ||< q
||fS )z
    Returns two dictionaries, one containing all the items whose keys do not
    start with a prefix and another containing all the items whose keys do start
    with the prefix. Note that the prefix is not removed from the keys.
    )r   r[   rR   )drU   	no_prefixwith_prefixrS   r   r   r	   split_dict_by_key_prefix   s   
rg   N)F)
r
   r   r   r   r#   r*   rM   rP   rc   rg   r   r   r   r	   <module>   s   

AA@