
    6Dh\                        S SK Jr  S SKJr  SSKJrJrJr  SSK	J
r
JrJr  S SKJs  Jr  S SKrS SKrS SKJr   S SKrSr/ rSS	 jrS
 rSSS0 SSSSSSSSSSSSSSSSSSSSS4S\R8                  4S jjrg! \ a    Sr NAf = f)    N)ColorscaleValidator   )apply_default_cascadeinit_figureconfigure_animation_controls)rescale_intensity_integer_ranges_integer_types)image_array_to_data_uriTFc                 8   US:X  a  SOSnU c  U $ [         R                  " U 5      (       a
  U /S-  U/-   $ [        U 5      S:X  a  [        U 5      S-  U/-   $ [        U 5      S:X  a  [        U 5      U/-   $ [        U 5      S:X  a  U $ [	        S[        U 5      -  5      e)Nmax   r      r      z\zmax can be a scalar, or an iterable of length 1, 3 or 4. A value of %s was passed for zmax.)npisscalarlenlist
ValueErrorstr)zmodealphas      H/var/www/html/env/lib/python3.13/site-packages/plotly/express/_imshow.py_vectorize_zvaluer      s    5=CaEy	QsQw%  	Q1Aw{eW$$	Q1Aw%  	Q1136q6:
 	
    c                     U R                   R                  nSnU[        ;   a  [        U   S   $ U [        R
                  " U 5         R                  5       nUSU-  ::  a  gUSU-  ::  a  gUSU-  ::  a  gg)Ng?r   r   i  l        )dtypetyper
   r	   r   isfiniter   )imgdtrtolim_maxs       r   _infer_zmax_from_typer%   '   sx    	BD	^r"1%%R[[%&**,QXsTz!ut|#r   autor   pngreturnc                    [        5       n[        U5        UR                  5       nSnUbr  [        U[        5      (       a  U R
                  R                  U5      nU R                  U   n[        U5      nU	b  [        U	5      OUnUU-  (       a  UU-  S-   OUU-  nOSnSnUbJ  [        U[        5      (       a  U R
                  R                  U5      nU R                  U   n[        U5      n USLUSL-   n!Sn"Sn#Sn$[        (       Gaj  [        U [        R                  5      (       GaJ  [        U R
                  5      n%Sn$/ n&UbF  U R                  U R
                  U      R                  nU&R!                  U5        U R
                  U   n"UbF  U R                  U R
                  U      R                  n U&R!                  U5        U R
                  U   n#[#        U&SS9 H  n'U%R%                  U'5      n(M     U%S   U%S   n*n)U*U)4 Hu  n+[&        R(                  " U R                  U+   R*                  [&        R,                  5      (       d  MF  U R                  U+   R/                  [        5      U R                  U+'   Mw     Uc  U R                  U*   R                  nUc  U R                  U)   R                  nUc  SnUR1                  SS5      c  U*US'   UR1                  S	S5      c  U)US	'   UR1                  S
S5      c  U#US
'   UR1                  SS5      c  U"US'   UR1                  SS5      cD  [        R2                  R4                  R7                  U 5      US'   US   R9                  SS5      US'   GOc[;        U S5      (       az  [;        U R<                  S5      (       a_  Uc  U R<                  nUR1                  SS5      c=  [;        U R<                  S5      (       a"  U R<                  R>                  =(       d    SUS'   [;        U S5      (       az  [;        U R                  S5      (       a_  Uc  U R                  nUR1                  S	S5      c=  [;        U R                  S5      (       a"  U R                  R>                  =(       d    SUS	'   UR1                  SS5      c  SUS'   UR1                  S	S5      c  SUS	'   UR1                  SS5      c  SUS'   Uc  Sn[@        RB                  " U SS9n [        U [@        RD                  5      (       a  U(       a  [G        S5      eSn,OSn,[&        RH                  " U 5      n Ub&  [&        RJ                  " XS5      n Ub
  Xx:  a  US-  nSnUb5  [&        RJ                  " XS5      n SnUR1                  S
5      c  S
OUS
   US
'   Sn-Ub  U-[        W5      4-  n-Ub  U-[        U5      4-  n-Uc   U RL                  SU!-   :  =(       a    U,(       + nU R*                  [N        :X  a"  SU R/                  [&        RP                  5      -  n Ub
  US   nUS   nUc  U RL                  SU!-   :X  a  SOSnUS:X  a;  Uc  U(       a  Uc  U RS                  5       nUc  U(       a  Uc  U RU                  5       nO4Uc)  U R*                  [&        RP                  :w  a  [W        U 5      nUc  Ub  SnU RL                  SU!-   :X  GaN  U(       GdF  U!n.Ub'  U R                  U.   [Y        U5      :w  a  [G        S5      eU!S-   n/Ub'  U R                  U/   [Y        U5      :w  a  [G        S5      eSn0USL a  Sn0OUSLa  S U-   S!-   n0[[        [\        R^                  " U-6 5       V1V2s/ s H+  u  n1n2[`        Rb                  " UUU U2   S"[	        U15      U0S#9PM-     n3n1n2US$:X  a  SOS%n4[e        [e        U4S&9S'9n5US:X  a  [e        S	S(S)9U5S*'   S(U5S+   S,'   [g        S-S.5      n6[e        U6Ri                  US/   5      UUUS09U5S"'   US   (       a  [e        US   S19U5S"   S2'   GOU RL                  S:  a!  U R                  S3   S4;   d'  U!(       a  U(       d  U RL                  S:X  Ga  U(       Ga  Sn7Ub  Ub  [k        US5S69[k        US7S69p!S8u  n8n9n:n;S9n<Ubq  [&        RH                  " U5      n[&        R(                  " UR*                  [&        Rl                  5      (       a  US   n8US   US   -
  n:OU$(       a  U<OS:n=[G        U=5      eUbq  [&        RH                  " U5      n[&        R(                  " UR*                  [&        Rl                  5      (       a  US   n9US   US   -
  n;OU$(       a  U<OS;n=[G        U=5      eU(       Ga  Uc  Uc  U n>Sn7OU RL                  SU!-   :X  a!  [o        XS   US   4[&        RP                  S<9n>O`[&        Rp                  " [        U R                  S3   5       V?s/ s H)  n?[o        U S=U?4   UU?   UU?   4[&        RP                  S<9PM+     sn?S3S>9n>[\        R^                  " U-6  V2s/ s H  n2[s        U>U2   UUUS?9PM     n@n2[[        U@5       V1VAs/ s H(  u  n1nA[`        Rt                  " UA[	        U15      U8U9U:U;S@9PM*     n3n1nAOVU R                  S3   S:X  a  SAOSBnB[\        R^                  " U-6  V2s/ s H!  n2[`        Rt                  " U U2   UUWBU8U9U:U;SC9PM#     n3n20 n5US$:X  d	  U;b  U;S:  a  [e        SS&9U5S+'   U:b  U:S:  a  [e        S%S&9U5S*'   O![G        SD[	        U R                  5      -  5      e/ nCUb0  UR1                  S5      c  SOUS   nDW V1s/ s H
  n1WD SEU1 3PM     nCn1[w        USF/ UUWC/ 5      nESG H  nFUUF   (       d  M  UWF   U5UF'   M     USH   (       a	  USH   U5SI'   O+USJ   Rx                  Rz                  R|                  c  SKSL0U5SM'   / nG[[        U35       H;  u  n'nHU(       a	  U'UU-  :  d  U'S:X  d  M  WER                  WHUU'U-  -
  U'U-  S-   SN9  M=     UbN  [        [        W5      W 5       H5  u  n1n'WGR!                  [e        U3UU1-  UU1S-   -   U5[	        U'5      SO95        M7     U(       a  WGWElA        WER                  U55        U(       aH  W7(       aA  [&        R                  " U W>:H  5      (       d#  US   =(       d    S< SPUS	   =(       d    S	< SQ3nIO}WHSR   SS:X  a  SnJO;U RL                  S:X  a  STnJO(U RL                  S:X  a  U R                  S3   S:X  a  SUnJOSnJUS   =(       d    S< SPUS	   =(       d    S	< SVUS   =(       d    S< SWWJ< SX3nIWER                  WISY9  US   (       a  WER                  US   SSZ9  US	   (       a  WER                  US	   SS[9  [        U[`        Rt                  WE5        UER                  USJ   SS\9  UE$ s  sn2n1f s  sn?f s  sn2f s  snAn1f s  sn2f s  sn1f )]a  
Display an image, i.e. data on a 2D regular raster.

Parameters
----------

img: array-like image, or xarray
    The image data. Supported array shapes are

    - (M, N): an image with scalar data. The data is visualized
      using a colormap.
    - (M, N, 3): an image with RGB values.
    - (M, N, 4): an image with RGBA values, i.e. including transparency.

zmin, zmax : scalar or iterable, optional
    zmin and zmax define the scalar range that the colormap covers. By default,
    zmin and zmax correspond to the min and max values of the datatype for integer
    datatypes (ie [0-255] for uint8 images, [0, 65535] for uint16 images, etc.). For
    a multichannel image of floats, the max of the image is computed and zmax is the
    smallest power of 256 (1, 255, 65535) greater than this max value,
    with a 5% tolerance. For a single-channel image, the max of the image is used.
    Overridden by range_color.

origin : str, 'upper' or 'lower' (default 'upper')
    position of the [0, 0] pixel of the image array, in the upper left or lower left
    corner. The convention 'upper' is typically used for matrices and images.

labels : dict with str keys and str values (default `{}`)
    Sets names used in the figure for axis titles (keys ``x`` and ``y``),
    colorbar title and hoverlabel (key ``color``). The values should correspond
    to the desired label to be displayed. If ``img`` is an xarray, dimension
    names are used for axis titles, and long name for the colorbar title
    (unless overridden in ``labels``). Possible keys are: x, y, and color.

x, y: list-like, optional
    x and y are used to label the axes of single-channel heatmap visualizations and
    their lengths must match the lengths of the second and first dimensions of the
    img argument. They are auto-populated if the input is an xarray.

animation_frame: int or str, optional (default None)
    axis number along which the image array is sliced to create an animation plot.
    If `img` is an xarray, `animation_frame` can be the name of one the dimensions.

facet_col: int or str, optional (default None)
    axis number along which the image array is sliced to create a facetted plot.
    If `img` is an xarray, `facet_col` can be the name of one the dimensions.

facet_col_wrap: int
    Maximum number of facet columns. Wraps the column variable at this width,
    so that the column facets span multiple rows.
    Ignored if `facet_col` is None.

facet_col_spacing: float between 0 and 1
    Spacing between facet columns, in paper units. Default is 0.02.

facet_row_spacing: float between 0 and 1
    Spacing between facet rows created when ``facet_col_wrap`` is used, in
    paper units. Default is 0.0.7.

color_continuous_scale : str or list of str
    colormap used to map scalar data to colors (for a 2D image). This parameter is
    not used for RGB or RGBA images. If a string is provided, it should be the name
    of a known color scale, and if a list is provided, it should be a list of CSS-
    compatible colors.

color_continuous_midpoint : number
    If set, computes the bounds of the continuous color scale to have the desired
    midpoint. Overridden by range_color or zmin and zmax.

range_color : list of two numbers
    If provided, overrides auto-scaling on the continuous color scale, including
    overriding `color_continuous_midpoint`. Also overrides zmin and zmax. Used only
    for single-channel images.

title : str
    The figure title.

template : str or dict or plotly.graph_objects.layout.Template instance
    The figure template name or definition.

width : number
    The figure width in pixels.

height: number
    The figure height in pixels.

aspect: 'equal', 'auto', or None
  - 'equal': Ensures an aspect ratio of 1 or pixels (square pixels)
  - 'auto': The axes is kept fixed and the aspect ratio of pixels is
    adjusted so that the data fit in the axes. In general, this will
    result in non-square pixels.
  - if None, 'equal' is used for numpy arrays and 'auto' for xarrays
    (which have typically heterogeneous coordinates)

contrast_rescaling: 'minmax', 'infer', or None
    how to determine data values corresponding to the bounds of the color
    range, when zmin or zmax are not passed. If `minmax`, the min and max
    values of the image are used. If `infer`, a heuristic based on the image
    data type is used.

binary_string: bool, default None
    if True, the image data are first rescaled and encoded as uint8 and
    then passed to plotly.js as a b64 PNG string. If False, data are passed
    unchanged as a numerical array. Setting to True may lead to performance
    gains, at the cost of a loss of precision depending on the original data
    type. If None, use_binary_string is set to True for multichannel (eg) RGB
    arrays, and to False for single-channel (2D) arrays. 2D arrays are
    represented as grayscale and with no colorbar if use_binary_string is
    True.

binary_backend: str, 'auto' (default), 'pil' or 'pypng'
    Third-party package for the transformation of numpy arrays to
    png b64 strings. If 'auto', Pillow is used if installed,  otherwise
    pypng.

binary_compression_level: int, between 0 and 9 (default 4)
    png compression level to be passed to the backend when transforming an
    array to a png b64 string. Increasing `binary_compression` decreases the
    size of the png string, but the compression step takes more time. For most
    images it is not worth using levels greater than 5, but it's possible to
    test `len(fig.data[0].source)` and to time the execution of `imshow` to
    tune the level of compression. 0 means no compression (not recommended).

binary_format: str, 'png' (default) or 'jpg'
    compression format used to generate b64 string. 'png' is recommended
    since it uses lossless compression, but 'jpg' (lossy) compression can
    result if smaller binary strings for natural images.

text_auto: bool or str (default `False`)
    If `True` or a string, single-channel `img` values will be displayed as text.
    A string like `'.2f'` will be interpreted as a `texttemplate` numeric formatting directive.

Returns
-------
fig : graph_objects.Figure containing the displayed image

See also
--------

plotly.graph_objects.Image : image trace
plotly.graph_objects.Heatmap : heatmap trace

Notes
-----

In order to update and customize the returned figure, use
`go.Figure.update_traces` or `go.Figure.update_layout`.

If an xarray is passed, dimensions names and coordinates are used for
axes labels and ticks.
r   NFT)reverser   r&   xyanimation_frame	facet_colcolor
z<br>columns__len__name indexequal)pass_throughz0Binary strings cannot be used with pandas arrays r   r      minmaxinferzZThe length of the y vector must match the length of the first dimension of the img matrix.z[The length of the x vector must match the length of the second dimension of the img matrix.z%{z}z%{z:}
coloraxis1)r+   r,   r   	coloraxisr3   texttemplatelowerreversed)	autorange)yaxisdomain)scaleanchor	constrainxaxisrC   rF   
colorscaleimshowcolor_continuous_scale)rH   cmidcmincmax)
title_textcolorbar)r   r   min)r   r   )NNNNzNon-numerical coordinates were passed with xarray `img`, but the Image trace cannot handle it. Please use `binary_string=False` for 2D data or pass instead the numpy array `img.values` to `px.imshow`.zUOnly numerical values are accepted for the `x` parameter when an Image trace is used.zUOnly numerical values are accepted for the `y` parameter when an Image trace is used.)in_range	out_range.)axis)backendcompressionext)sourcer3   x0y0dxdyrgbrgba256)r   zminzmax
colormodelrY   rZ   r[   r\   zpx.imshow only accepts 2D single-channel, RGB or RGBA images. An image of shape %s was provided. Alternatively, 3- or 4-D single or multichannel datasets can be visualized using the `facet_col` or/and `animation_frame` arguments.=xy)heightwidthtitlerN   templatet<   margin)rowcol)datalayoutr3   z
: %{x}<br>z: %{y}<extra></extra>r   heatmapz%{z[0]}z[%{z[0]}, %{z[1]}, %{z[2]}]z
: %{y}<br>z: z<extra></extra>)hovertemplate)rN   rk   )rN   rl   )rg   	overwrite)Hlocalsr   copy
isinstancer   dimsr5   shaperangeintxarray_importedxarray	DataArrayr   coordsvaluesappendsortedpopr   
issubdtyper   
datetime64astypegetplotutilslabel_from_attrsreplacehasattrr1   r3   nwfrom_native	DataFramer   
asanyarraymoveaxisndimbooluint8r   rQ   r%   r   	enumerate	itertoolsproductgoHeatmapdictr   validate_coercer   numberr   stackr   Imager   rn   rj   rh   	add_tracezipframesupdate_layoutallupdate_tracesupdate_xaxesupdate_yaxesr   )Kr!   r_   r`   originlabelsr+   r,   r-   r.   facet_col_wrapfacet_col_spacingfacet_row_spacingrJ   color_continuous_midpointrange_colorrf   rg   re   rd   aspectcontrast_rescalingbinary_stringbinary_backendbinary_compression_levelbinary_format	text_autoargsnslices_facetfacet_slicesncolsnrowsnslices_animationanimation_slicesslice_dimensionsfacet_labelanimation_labelimg_is_xarrayru   pop_indexesr5   _y_labelx_labelaxis_dataframe	iterablesy_indexx_indexr?   i	index_tuptracesrB   rn   colorscale_validatorrescale_imagerY   rZ   r[   r\   error_msg_xarray	error_msgimg_rescaledchimg_strimg_str_slicera   
col_labelsslice_labelfig	attr_name
frame_listtracerp   
hover_namesK                                                                              r   rI   rI   8   s   f 8D$[[]FMi%%y1I		),]+'5'AN#} u$ U"Q&%' 	 "os++!hhnn_=OIIo6 !23!-t# KOM:c6+;+;<<CHH~ ::chhy&9:AALy)((9-K&"zz#((?*CDKK/!hh7OK6EA 77DGG$B}}SZZ^112==AA!$B!6!6s!;

2 % 9

7#**A9

7#**A>F::c4 (!F3K::c4 (!F3K::'.6(7F$%::k4(0"-F;::gt$,$kk//@@EF7O$Wo55dFCF7O3	""ws{{I'F'FyKKzz#t$,f1M1M!kk..4"s3  WSYY	%B%ByIIzz#t$,F1K1K!iinn2s::c4 (F3K::c4 (F3K::gt$, F7O>F ..4
0C#r||$$OPP --
Ckk#!,&?+Fq O	"kk#2 zz+,4 )* 	
 I"e-.00	eM*,,	 Q)9%9:O<?O yyDCJJrxx((1~1~ !),a:J6J)KXQX X%4<779D4<779D <CII1(-D<D,D xx1'''"=SYYw/3q691  #Q&=SYYw/3q691 
 !Le#!I-3L !*)*;*;Y*G H

 !I9 JJi.&V) !I 	 

 #g-D:	D956W"shGF7O+3F7OK(2<J#+;;-. + 
| '?/3vg/OF< , 	AYYr]f$(8]
((a-M 0!$U3!$U3  %BBW 	
 =a A}}QWWbii00qTqTAaD[ % %7	  !++=a A}}QWWbii00qTqTAaD[ % %7	  !++|" %Q!11107DG"4   "xx #(		""6 #7B *RL&*2hR%9&(hh
 #7 
 $ "+!2!2I!> "?I ( +* 8%	 "?   )2'(:(:$A} CFrbRTVW(:  F
 #&))B-1"4)J "+!2!2I!> "?I )n)	 "?   WBF"T2F7O>b1f"Z8F7OS #))n	
 	
 J!::k2:K{@S 	 5AALqQqc*L
A
dD"eUJ
CC(		?? $YF9 ) G}#G}|	j		 	 	'	'	)	)	19xJ!&)u%%%-/EQJMM%UUe^%;QRARMS * "E"346FGHAu 1MQU4KL!U H 
frvvc\6I/J/J 3K33K3

 =I%JXX]"JXX]syy}16JJ3K33K37O&w&	
 M2c{F3KQ7c{F3KQ7 rxx5tJ/4@JQ

jB Bs$    2w0w'w/w/(w%w*)r   )plotly.graph_objs
graph_objsr   _plotly_utils.basevalidatorsr   _corer   r   r   imshow_utilsr   r	   r
   narwhals.stable.v1stablev1r   numpyr   r   plotly.utilsr   rz   ry   ImportError_float_typesr   r%   FigurerI   r8   r   r   <module>r      s     < S S L L     0O 
&& 
	

"

5e6 YY7eU  Os   A6 6B B