*L i^ddlmZddlmZdZdZdZdZdZdZ d Z d d Z dd Z y ))Sequence) exceptionscHt|txrt|t SN) isinstancerstr)objs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/plotly/figure_factory/utils.py is_sequencer s c8 $ AZS-A)AAcddlmt|dr*tfd|Dst j dyt|dt r(td|Dst j dyy)z Validates if a list contains all numbers or all strings :raises: (PlotlyError) If there are any two items in the list whose types differ rNumberc36K|]}t|ywrr.0itemrs r z!validate_index..sC:dF+Cz^Error in indexing column. Make sure all entries of each column are all numbers or all strings.c3<K|]}t|tywrrrrrs r rz!validate_index..s@T:dC(@Nnumbersrrallr PlotlyErrorr) index_valsrs @r validate_indexr s*Q-(C CC(( D JqM3 '@Z@@(( A (r cddlm|D]v}t|dr*tfd|Dr't j dt|dt sPtd|Drct j dy)z Validates all strings or numbers in each dataframe column :raises: (PlotlyError) If there are any two items in any list whose types differ rrc36K|]}t|ywrrrs r rz%validate_dataframe..1sCDz$/CrzWError in dataframe. Make sure all entries of each column are either numbers or strings.c3<K|]}t|tywrrrs r rz%validate_dataframe..9s@z$,@rNr)arrayvectorrs @r validate_dataframer&&s fQi (CFCC ,,* q 3 '@@@ ,,*r ctt|dtfd|Drtjdy)z Validates that data lists or ndarrays are the same length. :raises: (PlotlyError) If any data lists are not the same length. rc3:K|]}t|k7ywr)len)rlstlengths r rz(validate_equal_length..Is .#3s8v  .sz 0, got {}z{} must be a number, got {}N)items ValueErrorformat TypeErrorrr)kwargskeyvals r validate_positive_scalarsr7Os}LLNYS Yax !9!@!@c!JKKY Y(()F)M)McSV)WX X Ys ;/A*c |Dcgc] }|D]}| c}}Scc}}w#t$rtjdwxYw)z Uses list comprehension to flatten array :param (array): An iterable to flatten :raises (PlotlyError): If iterable is not nested. :rtype (list): The flattened list. z\Your data array could not be flattened! Make sure your data is entered as lists or ndarrays!)r3rr)r$sublistrs r flattenr:_sN $)>g>d>>>>  $$ ,   s!!!Acrt|}t|ts%t|tst j d|D]'}t|t st j dt|dz D]%}||||dzk\st j dg}|jtd|dgt|dz D]@}g}|j|||j||dz|j|B|j||dz tdg|S)a Returns a list of intervals for categorical colormaps Accepts a list or tuple of sequentially increasing numbers and returns a list representation of the mathematical intervals with these numbers as endpoints. For example, [1, 6] returns [[-inf, 1], [1, 6], [6, inf]] :raises: (PlotlyError) If input is not a list or tuple :raises: (PlotlyError) If the input contains a string :raises: (PlotlyError) If any number does not increase after the previous one in the sequence zZThe intervals_endpts argument must be a list or tuple of a sequence of increasing numbers.z-infrinf) r)rtuplelistrrrrangeappendfloat)endptsr+rk intervalsintervals r endpts_to_intervalsrGqsJ[F v ':ft+E$$ %   dC (( 6A:  !9q1u %((  %-34vz" 'AH OOF1I & OOF1q5M *   X &  ' &!,eEl;<r cbd|dz |zz |z }|s:d} d} |dk(r|dz ||zzd|zz} d} d} n_|dk(rZ|dz ||zzd|zz} d} d } nD|dk(rd} d } |dz ||zzd|zz} d } d } n%|dk(r d} |dz ||zzd|zz} |rd } d } nd} d} d} t     ddd|td| }|S)a# Returns annotation dict for label of n labels of a 1xn or nx1 subplot. :param (str) text: the text for a label. :param (int) lane: the label number for text. From 1 to n inclusive. :param (int) num_of_lanes: the number 'n' of rows or columns in subplot. :param (float) subplot_spacing: the value for the horizontal_spacing and vertical_spacing params in your plotly.tools.make_subplots() call. :param (str) row_col: choose whether labels are placed along rows or columns. :param (bool) flipped: flips text by 90 degrees. Text is printed horizontally if set to True and row_col='row', or if False and row_col='col'. :param (bool) right_side: only applicable if row_col is set to 'row'. :param (str) text_color: color of the text. r<centermiddlecolg?g{Gz?rrowZbottomg?ileftg{GzrightFpaper )sizecolor) textanglexanchoryanchorxy showarrowxrefyreftextfont)dict)r]lane num_of_lanessubplot_spacingrow_colflipped right_side text_colortemprVrWrXrYrUannotation_dicts r annotation_dict_for_labelris:4 !_4 4 FD  e d_45d BAAI  d_45d BAAI e GGd_45d BAAI  Gd_45d BA !I     r , O r ct|dkrtjdt|dz dzdz|zdz|dzz}|j|S)z Returns an English listing of objects seperated by commas ',' For example, ['foo', 'bar', 'baz'] becomes 'foo, bar and baz' if the conjunction 'and' is selected. z1Your list or tuple must contain at least 2 items.z{}, z{} z {}.)r)rrr2)iterableconjperiodtemplates r list_of_optionsrqsd 8}q$$ ?  H !V+e3d:UBVc\QH 8??H %%r N)rKTTz#0f0f0f)andT) collections.abcrplotlyrr r r&r.r7r:rGrirqr r rvsK$B88   Y  $2t  DN &r