
    -eD                       d Z ddlmZ ddlZ ej        e          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mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z  dd
l!m"Z" ddl#m$Z$ ddl%m&Z& dZ'e G d de&                      Z(e G d de(                      Z) G d de)          Z*e G d de)                      Z+ G d de+          Z, G d de(          Z-dS )z Models for describing different kinds of ranges of values
in different kinds of spaces (e.g., continuous or categorical)
and with options for "auto sizing".

    )annotationsN)Counter)nan   )PaddingUnitsStartEnd)abstract)AutoBoolDatetimeEitherEnum	FactorSeqFloatInstanceListMinMaxBoundsNullNullableOverrideReadonlyRequired	TimeDelta)error)DUPLICATE_FACTORS)Model)	DataRangeDataRange1dFactorRangeRangeRange1dc                  $     e Zd ZdZd fdZ xZS )r    z( A base class for all range types.

    returnNonec                :     t                      j        |i | d S Nsuper__init__selfargskwargs	__class__s      3lib/python3.11/site-packages/bokeh/models/ranges.pyr)   zRange.__init__M   %    $)&)))))    r#   r$   )__name__
__module____qualname____doc__r)   __classcell__r.   s   @r/   r    r    F   sG         
* * * * * * * * * *r1   r    c                       e Zd ZdZd fdZ e eeee	          d          Z
 e eeee	          d          Z xZS )	NumericalRangez) A base class for numerical ranges.

    r#   r$   c                :     t                      j        |i | d S r&   r'   r*   s      r/   r)   zNumericalRange.__init__W   r0   r1   z!
    The start of the range.
    helpz
    The end of the range.
    r2   )r3   r4   r5   r6   r)   r   r   r   r   r   startendr7   r8   s   @r/   r:   r:   P   s         
* * * * * * HVVE8Y77 ? 	 	 	E (66%955 = 	 	 	CCCCCr1   r:   c                       e Zd ZdZd fdZ eeeee	d          Z
 eeeee	d          Z e ed	          d
          Z eeee	d          Z eeee	d          Z ed          Z ed          Z xZS )r!   a1   A fixed, closed range [start, end] in a continuous scalar
    dimension.

    In addition to supplying ``start`` and ``end`` keyword arguments
    to the ``Range1d`` initializer, you can also instantiate with
    the convenience syntax::

        Range(0, 10) # equivalent to Range(start=0, end=10)

    r#   r$   c                    |rd|v sd|v rt          d          |r"t          |          dk    rt          d          |r|d         |d<   |d         |d<    t                      j        di | d S )	Nr>   r?   zC'start' and 'end' keywords cannot be used with positional argumentsr   zCOnly Range1d(start, end) acceptable when using positional argumentsr       )
ValueErrorlenr(   r)   r*   s      r/   r)   zRange1d.__init__n   s     	dW&&%6//bccc 	dCIINNbccc 	$"1gF7O GF5M""6"""""r1   z
    The start of the range to apply after reset. If set to ``None`` defaults
    to the ``start`` value during initialization.
    r<   z
    The end of the range to apply when resetting. If set to ``None`` defaults
    to the ``end`` value during initialization.
    Taccept_datetimea  
    The bounds that the range is allowed to go to. Typically used to prevent
    the user from panning/zooming/etc away from the data.

    If set to ``'auto'``, the bounds will be computed to the start and end of the Range.

    Bounds are provided as a tuple of ``(min, max)`` so regardless of whether your range is
    increasing or decreasing, the first item should be the minimum value of the range and the
    second item should be the maximum. Setting min > max will result in a ``ValueError``.

    By default, bounds are ``None`` and your plot to pan/zoom as far as you want. If you only
    want to constrain one end of the plot, you can set min or max to None.

    Examples:

    .. code-block:: python

        Range1d(0, 1, bounds='auto')  # Auto-bounded to 0 and 1 (Default behavior)
        Range1d(start=0, end=1, bounds=(0, None))  # Maximum is unbounded, minimum bounded to 0

    z
    The level that the range is allowed to zoom in, expressed as the
    minimum visible interval. If set to ``None`` (default), the minimum
    interval is not bound. Can be a ``TimeDelta``. z
    The level that the range is allowed to zoom out, expressed as the
    maximum visible interval. Can be a ``TimeDelta``. Note that ``bounds`` can
    impose an implicit constraint on the maximum interval as well. r   defaultrB   r2   )r3   r4   r5   r6   r)   r   r   r   r   r   reset_start	reset_endr   r   boundsmin_intervalmax_intervalr   r>   r?   r7   r8   s   @r/   r!   r!   b   s#       	 	
# 
# 
# 
# 
# 
# &uh	 A 	 	 	K
 tUHi ? 	 	 	I
 Xll4888 @ 	 	 	F, 6$y 87 8 8 8L
 6$y 8G H H HL
 HQE
(1


CCCCCr1   r!   c                       e Zd ZdZd fdZ e e ee                    e	d          Z
 ee          Z ee          Z xZS )	r   z- A base class for all data range types.

    r#   r$   c                :     t                      j        |i | d S r&   r'   r*   s      r/   r)   zDataRange.__init__   r0   r1   zp
    An explicit list of renderers to autorange against. If unset,
    defaults to all renderers on a plot.
    r<   rH   r2   )r3   r4   r5   r6   r)   r   r   r   r   r
   	renderersr   r   r>   r?   r7   r8   s   @r/   r   r      s         
* * * * * * ttHHUOO,,d : 	 	 	I
 HS!!!E
(3


CCCCCr1   r   c                  t    e Zd ZdZd fdZ eeedd          Z e	e
dd	          Z e ed
          d          Z eeeed          Z eeeed          Z edd          Z e e	e          d          Z e eee          d          Z eeedd          Z edd          Z xZS )r   z An auto-fitting range in a continuous scalar dimension.

    By default the ``start`` and ``end`` of the range automatically
    assume min and max values of the data for associated renderers.

    r#   r$   c                n    |                     d          d |d<    t                      j        |i | d S )NfollowrL   )getr(   r)   r*   s      r/   r)   zDataRange1d.__init__   sA    ::h+#F8$)&)))))r1   g?an  
    How much padding to add around the computed data bounds.

    When ``range_padding_units`` is set to ``"percent"``, the span of the
    range span is expanded to make the range ``range_padding`` percent larger.

    When ``range_padding_units`` is set to ``"absolute"``, the start and end
    of the range span are extended by the amount ``range_padding``.
    rI   r=   percent
    Whether the ``range_padding`` should be interpreted as a percentage, or
    as an absolute quantity. (default: ``"percent"``)
    TrF   a  
    The bounds that the range is allowed to go to. Typically used to prevent
    the user from panning/zooming/etc away from the data.

    By default, the bounds will be None, allowing your plot to pan/zoom as far
    as you want. If bounds are 'auto' they will be computed to be the same as
    the start and end of the ``DataRange1d``.

    Bounds are provided as a tuple of ``(min, max)`` so regardless of whether
    your range is increasing or decreasing, the first item should be the
    minimum value of the range and the second item should be the maximum.
    Setting ``min > max`` will result in a ``ValueError``.

    If you only want to constrain one end of the plot, you can set ``min`` or
    ``max`` to ``None`` e.g. ``DataRange1d(bounds=(None, 12))``
    r<   z
    The level that the range is allowed to zoom in, expressed as the
    minimum visible interval. If set to ``None`` (default), the minimum
    interval is not bound.z
    The level that the range is allowed to zoom out, expressed as the
    maximum visible interval. Note that ``bounds`` can impose an
    implicit constraint on the maximum interval as well.Fz`
    Whether the range should be "flipped" from its normal direction when
    auto-ranging.
    a  
    Configure the data to follow one or the other data extreme, with a
    maximum range size of ``follow_interval``.

    If set to ``"start"`` then the range will adjust so that ``start`` always
    corresponds to the minimum data value (or maximum, if ``flipped`` is
    ``True``).

    If set to ``"end"`` then the range will adjust so that ``end`` always
    corresponds to the maximum data value (or minimum, if ``flipped`` is
    ``True``).

    If set to ``None`` (default), then auto-ranging does not follow, and
    the range will encompass both the minimum and maximum data values.

    ``follow`` cannot be used with bounds, and if set, bounds will be set to
    ``None``.
    z
    If ``follow`` is set to ``"start"`` or ``"end"`` then the range will
    always be constrained to that::

         abs(r.start - r.end) <= follow_interval

    is maintained.

    g       @z
    A default width for the interval, in case ``start`` is equal to ``end``
    (if used with a log axis, default_span is in powers of 10).
    zo
    If True, renderers that that are not visible will be excluded from automatic
    bounds computations.
    r2   )r3   r4   r5   r6   r)   r   r   r   range_paddingr   r   range_padding_unitsr   r   rL   r   rM   rN   r   flippedr   rT   follow_intervaldefault_spanonly_visibler7   r8   s   @r/   r   r      s        * * * * * *
 F5)S @ 	 	 	M $|Y F 	 	 	
 Xll4888 @ 	 	 	F" 6$y 8   L
 6$y 8< = = =L
 d5 ( 	 	 	G
 Xdd8nn , 	 	 	F& hvveY77 ? 	 	 	O 6%C ? 	 	 	L
 4 - 	 	 	LLLLLr1   r   c                      e Zd ZdZ eg d          Z edd          Z edd          Z edd	          Z	 ed
d          Z
 eedd          Z eed
d          Z eed
d          Z e ed          d          Z eed          Z eed          Zd fdZ ee          d             Z xZS )r   a   A Range of values for a categorical dimension.

    In addition to supplying ``factors`` as a keyword argument to the
    ``FactorRange`` initializer, you may also instantiate with a sequence of
    positional arguments:

    .. code-block:: python

        FactorRange("foo", "bar") # equivalent to FactorRange(factors=["foo", "bar"])

    Users will normally supply categorical values directly:

    .. code-block:: python

        p.circle(x=["foo", "bar"], ...)

    BokehJS will create a mapping from ``"foo"`` and ``"bar"`` to a numerical
    coordinate system called *synthetic coordinates*. In the simplest cases,
    factors are separated by a distance of 1.0 in synthetic coordinates,
    however the exact mapping from factors to synthetic coordinates is
    affected by he padding properties as well as whether the number of levels
    the factors have.

    Users typically do not need to worry about the details of this mapping,
    however it can be useful to fine tune positions by adding offsets. When
    supplying factors as coordinates or values, it is possible to add an
    offset in the synthetic coordinate space by adding a final number value
    to a factor tuple. For example:

    .. code-block:: python

        p.circle(x=[("foo", 0.3), ...], ...)

    will position the first circle at an ``x`` position that is offset by
    adding 0.3 to the synthetic coordinate for ``"foo"``.

    aQ  
    A sequence of factors to define this categorical range.

    Factors may have 1, 2, or 3 levels. For 1-level factors, each factor is
    simply a string. For example:

    .. code-block:: python

        FactorRange(factors=["sales", "marketing", "engineering"])

    defines a range with three simple factors that might represent different
    units of a business.

    For 2- and 3- level factors, each factor is a tuple of strings:

    .. code-block:: python

        FactorRange(factors=[
            ["2016", "sales"], ["2016", "marketing"], ["2016", "engineering"],
            ["2017", "sales"], ["2017", "marketing"], ["2017", "engineering"],
        ])

    defines a range with six 2-level factors that might represent the three
    business units, grouped by year.

    Note that factors and sub-factors *may only be strings*.

    rV   g        z
    How much padding to add in between all lowest-level factors. When
    ``factor_padding`` is non-zero, every factor in every group will have the
    padding value applied.
    g?a)  
    How much padding to add in between mid-level groups of factors. This
    property only applies when the overall factors have three levels. For
    example with:

    .. code-block:: python

        FactorRange(factors=[
            ['foo', 'A', '1'],  ['foo', 'A', '2'], ['foo', 'A', '3'],
            ['foo', 'B', '2'],
            ['bar', 'A', '1'],  ['bar', 'A', '2']
        ])

    This property dictates how much padding to add between the three factors
    in the `['foo', 'A']` group, and between the two factors in the the
    [`bar`]
    gffffff?a  
    How much padding to add in between top-level groups of factors. This
    property only applies when the overall range factors have either two or
    three levels. For example, with:

    .. code-block:: python

        FactorRange(factors=[["foo", "1"], ["foo", "2"], ["bar", "1"]])

    The top level groups correspond to ``"foo"` and ``"bar"``, and the
    group padding will be applied between the factors ``["foo", "2"]`` and
    ``["bar", "1"]``
    r   az  
    How much padding to add around the outside of computed range bounds.

    When ``range_padding_units`` is set to ``"percent"``, the span of the
    range span is expanded to make the range ``range_padding`` percent larger.

    When ``range_padding_units`` is set to ``"absolute"``, the start and end
    of the range span are extended by the amount ``range_padding``.
    rW   rX   a[  
    The start of the range, in synthetic coordinates.

    .. note::
        Synthetic coordinates are only computed in the browser, based on the
        factors and various padding properties. The value of ``start`` will only
        be available in situations where bidirectional communication is
        available (e.g. server, notebook).
    aW  
    The end of the range, in synthetic coordinates.

    .. note::
        Synthetic coordinates are only computed in the browser, based on the
        factors and various padding properties. The value of ``end`` will only
        be available in situations where bidirectional communication is
        available (e.g. server, notebook).
    FrF   af  
    The bounds (in synthetic coordinates) that the range is allowed to go to.
    Typically used to prevent the user from panning/zooming/etc away from the
    data.

    .. note::
        Synthetic coordinates are only computed in the browser, based on the
        factors and various padding properties. Some experimentation may be
        required to arrive at bounds suitable for specific situations.

    By default, the bounds will be None, allowing your plot to pan/zoom as far
    as you want. If bounds are 'auto' they will be computed to be the same as
    the start and end of the ``FactorRange``.
    r<   a  
    The level that the range is allowed to zoom in, expressed as the
    minimum visible interval in synthetic coordinates. If set to ``None``
    (default), the minimum interval is not bounded.

    The default "width" of a category is 1.0 in synthetic coordinates.
    However, the distance between factors is affected by the various
    padding properties and whether or not factors are grouped.
    a  
    The level that the range is allowed to zoom out, expressed as the
    maximum visible interval in synthetic coordinates.. Note that ``bounds``
    can impose an implicit constraint on the maximum interval as well.

    The default "width" of a category is 1.0 in synthetic coordinates.
    However, the distance between factors is affected by the various
    padding properties and whether or not factors are grouped.
    r#   r$   c                    |rd|v rt          d          |rt          |          |d<    t                      j        di | d S )Nfactorsz:'factors' keyword cannot be used with positional argumentsrC   )rD   listr(   r)   r*   s      r/   r)   zFactorRange.__init__  s_     	+I''YZZZ 	+ $T

F9""6"""""r1   c                    d t          | j                                                  D             }|r"dd                    d |D                       z  S d S )Nc                $    g | ]\  }}|d k    |S )rB   rC   ).0itemcounts      r/   
<listcomp>z8FactorRange._check_duplicate_factors.<locals>.<listcomp>  s"    TTT+$%RS)))))r1   zduplicate factors found: %sz, c              3  4   K   | ]}t          |          V  d S r&   )repr)re   xs     r/   	<genexpr>z7FactorRange._check_duplicate_factors.<locals>.<genexpr>  s(      <T<TT!WW<T<T<T<T<T<Tr1   )r   ra   itemsjoin)r+   dupess     r/   _check_duplicate_factorsz$FactorRange._check_duplicate_factors  sf    TT)>)>)D)D)F)FTTT 	U0499<T<Te<T<T<T3T3TTT	U 	Ur1   r2   )r3   r4   r5   r6   r   ra   r   factor_paddingsubgroup_paddinggroup_paddingrY   r   r   rZ   r   r>   r?   r   r   rL   rM   rN   r)   r   r   rp   r7   r8   s   @r/   r   r     s       $ $L i * 	 	 	G: U3 . 	 	 	N uS 0 	 	 	$ E# - 	 	 	M E! + 	 	 	M $|Y F 	 	 	
 HUA - 	 	 	E (5! + 	 	 	C Xll5999 A 	 	 	F 8E ) 	 	 	L 8E ) 	 	 	L# # # # # # UU U U U U U Ur1   r   ).r6   
__future__r   logging	getLoggerr3   logcollectionsr   mathr   
core.enumsr   r   core.has_propsr	   core.propertiesr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   core.validationr   core.validation.errorsr   modelr   __all__r    r:   r!   r   r   r   rC   r1   r/   <module>r      s    # " " " " " g!!              0 / / / / / / / % % % % % %                                   $ $ # # # # # 6 6 6 6 6 6       
* * * * *E * * 
* 
	 	 	 	 	U 	 	 
	"D D D D Dn D D DL 
              
 $a	 a	 a	 a	 a	) a	 a	 a	F{U {U {U {U {U% {U {U {U {U {Ur1   