o
    dA`                     @  sz  U d Z ddlmZ ddlmZmZ ddlZddlmZm	Z	m
Z
mZmZmZmZ ddlZddlmZmZ ddlmZ G dd	 d	eZG d
d deZi Zded< i Zded< i Zded< dgZded< G dd deeZdsddZdtdud d!Z dvd#d$Z!dwdxd)d*Z"dtdyd+d,Z#dzd-d.Z$G d/d0 d0Z%G d1d2 d2ee Z&d3Z'd4Z(d5Z)d6Z*e&e e'a+e&e!e(a,e&e#e*Z-e&e"e)Z.e%eZ/G d7d8 d8eZ0	%		d{d|dAdBa1			d}d~dFdGZ2ddHdIZ3ddKdLZ4ddMdNZ5ddOdPZ6ddQdRZ7ddSdTZ8ddUdVZ9ddXdYZ:ddd`daZ;eddcddZ<ddhdiZ=ddjdkZ>ddldmZ?ddodpZ@e=eAZBe=eCZDe=eEZFe=eGZHe>eGeIfZJddqdrZKdS )a  
The config module holds package-wide configurables and provides
a uniform API for working with them.

Overview
========

This module supports the following requirements:
- options are referenced using keys in dot.notation, e.g. "x.y.option - z".
- keys are case-insensitive.
- functions should accept partial/regex keys, when unambiguous.
- options can be registered by modules at import time.
- options can be registered at init-time (via core.config_init)
- options have a default value, and (optionally) a description and
  validation function associated with them.
- options can be deprecated, in which case referencing them
  should produce a warning.
- deprecated options can optionally be rerouted to a replacement
  so that accessing a deprecated option reroutes to a differently
  named option.
- options can be reset to their default value.
- all option can be reset to their default value at once.
- all options in a certain sub - namespace can be reset at once.
- the user can set / get / reset or ask for the description of an option.
- a developer can register and mark an option as deprecated.
- you can register a callback to be invoked when the option value
  is set or reset. Changing the stored value is considered misuse, but
  is not verboten.

Implementation
==============

- Data is stored using nested dictionaries, and should be accessed
  through the provided API.

- "Registered options" and "Deprecated options" have metadata associated
  with them, which are stored in auxiliary dictionaries keyed on the
  fully-qualified key, e.g. "x.y.z.option".

- the config_init module is imported by the package's __init__.py file.
  placing any register_option() calls there will ensure those options
  are available as soon as pandas is loaded. If you use register_option
  in a module, it will only be available after that module is imported,
  which you should be aware of.

- `config_prefix` is a context_manager (for use with the `with` keyword)
  which can save developers some typing, see the docstring.

    )annotations)ContextDecoratorcontextmanagerN)AnyCallable	GeneratorGenericIterable
NamedTuplecast)FT)find_stack_levelc                   @  s.   e Zd ZU ded< ded< ded< ded< dS )DeprecatedOptionstrkey
str | Nonemsgrkeyremoval_verN__name__
__module____qualname____annotations__ r   r   Z/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/_config/config.pyr   L   s
   
 r   c                   @  s6   e Zd ZU ded< ded< ded< ded< ded	< d
S )RegisteredOptionr   r   objectdefvaldocCallable[[object], Any] | None	validatorCallable[[str], Any] | NonecbNr   r   r   r   r   r   S   s   
 r   zdict[str, DeprecatedOption]_deprecated_optionszdict[str, RegisteredOption]_registered_optionsdict[str, Any]_global_configall	list[str]_reserved_keysc                   @  s   e Zd ZdZdS )OptionErrorz^
    Exception raised for pandas.options.

    Backwards compatible with KeyError checks.
    N)r   r   r   __doc__r   r   r   r   r,   h   s    r,   patr   silentboolreturnc                 C  sf   t | }t|dkr|st|  tdt|  t|dkr#td|d }|s-t| t|}|S )Nr   zNo such keys(s):    zPattern matched multiple keys)_select_optionslen_warn_if_deprecatedr,   repr_translate_key)r.   r/   keysr   r   r   r   _get_single_keyt   s   r9   Fr   c                 C  s   t | |}t|\}}|| S N)r9   	_get_root)r.   r/   r   rootkr   r   r   _get_option   s   
r>   Nonec            
   	   O  s  t | }|r|d dkrtd|dd}|r(t| d }td| dt| d d d | dd d D ]G\}}t||}t|}|rN|j	rN|	| t
|\}	}||	|< |jr~|rytjd	d
 || W d    n1 ssw   Y  q7|| q7d S )N   r   z4Must provide an even number of non-keyword argumentsr/   Fz2_set_option() got an unexpected keyword argument ""r2   T)record)r4   
ValueErrorpoplistr8   	TypeErrorzipr9   _get_registered_optionr"   r;   r$   warningscatch_warnings)
argskwargsnargsr/   kwargr=   vr   or<   r   r   r   _set_option   s.   &



rQ    T_print_descr   c                 C  sD   t | }t|dkrtdddd |D }|r t| d S |S )Nr   No such keys(s)
c                 S     g | ]}t |qS r   )_build_option_description.0r=   r   r   r   
<listcomp>       z$_describe_option.<locals>.<listcomp>)r3   r4   r,   joinprint)r.   rS   r8   sr   r   r   _describe_option   s   r_   c                 C  sf   t | }t|dkrtdt|dkr"t| dk r"| dkr"td|D ]}t|t| j|d q$d S )Nr   rT   r2      r)   zYou must specify at least 4 characters when resetting multiple keys, use the special keyword "all" to reset all the options to their default valuer/   )r3   r4   r,   rC   rQ   r&   r   )r.   r/   r8   r=   r   r   r   _reset_option   s    rb   c                 C  s   t | dd}t|jS NTra   )r9   rH   r   )r.   r   r   r   r   get_default_val   s   
rd   c                   @  s:   e Zd ZdZddd	d
ZdddZdddZdddZdS )DictWrapperz/provide attribute-style access to a nested dictrR   dr'   prefixr   r1   r?   c                 C  s    t | d| t | d| d S )Nrf   rg   )r   __setattr__)selfrf   rg   r   r   r   __init__   s   zDictWrapper.__init__r   valr   c                 C  sP   t | d}|r|d7 }||7 }|| jv r$t| j| ts$t|| d S td)Nrg   .z.You can only set the value of existing options)r   __getattribute__rf   
isinstancedictrQ   r,   )ri   r   rk   rg   r   r   r   rh      s   zDictWrapper.__setattr__c              
   C  st   t | d}|r|d7 }||7 }z
t | d| }W n ty+ } ztd|d }~ww t|tr6t||S t|S )Nrg   rl   rf   zNo such option)r   rm   KeyErrorr,   rn   ro   re   r>   )ri   r   rg   rO   errr   r   r   __getattr__   s   


zDictWrapper.__getattr__Iterable[str]c                 C  s   t | j S r:   )rE   rf   r8   )ri   r   r   r   __dir__   s   zDictWrapper.__dir__N)rR   )rf   r'   rg   r   r1   r?   )r   r   rk   r   r1   r?   r   r   )r1   rs   )r   r   r   r-   rj   rh   rr   rt   r   r   r   r   re      s    

re   c                   @  s.   e Zd ZdddZdd
dZedddZdS )CallableDynamicDocfuncCallable[..., T]doc_tmplr   r1   r?   c                 C  s   || _ || _d S r:   )__doc_tmpl____func__)ri   rw   ry   r   r   r   rj      s   
zCallableDynamicDoc.__init__r   c                 O  s   | j |i |S r:   )r{   )ri   rK   kwdsr   r   r   __call__  s   zCallableDynamicDoc.__call__c                 C  s,   t ddd}ttt }| jj||dS )Nr)   F)rS   )	opts_desc	opts_list)r_   pp_options_listrE   r&   r8   rz   format)ri   r~   r   r   r   r   r-     s   zCallableDynamicDoc.__doc__N)rw   rx   ry   r   r1   r?   )r1   r   )r1   r   )r   r   r   rj   r}   propertyr-   r   r   r   r   rv      s
    

rv   a  
get_option(pat)

Retrieves the value of the specified option.

Available options:

{opts_list}

Parameters
----------
pat : str
    Regexp which should match a single option.
    Note: partial matches are supported for convenience, but unless you use the
    full option name (e.g. x.y.z.option_name), your code may break in future
    versions if new options with similar names are introduced.

Returns
-------
result : the value of the option

Raises
------
OptionError : if no such option exists

Notes
-----
Please reference the :ref:`User Guide <options>` for more information.

The available options with its descriptions:

{opts_desc}
a  
set_option(pat, value)

Sets the value of the specified option.

Available options:

{opts_list}

Parameters
----------
pat : str
    Regexp which should match a single option.
    Note: partial matches are supported for convenience, but unless you use the
    full option name (e.g. x.y.z.option_name), your code may break in future
    versions if new options with similar names are introduced.
value : object
    New value of option.

Returns
-------
None

Raises
------
OptionError if no such option exists

Notes
-----
Please reference the :ref:`User Guide <options>` for more information.

The available options with its descriptions:

{opts_desc}
a  
describe_option(pat, _print_desc=False)

Prints the description for one or more registered options.

Call with no arguments to get a listing for all registered options.

Available options:

{opts_list}

Parameters
----------
pat : str
    Regexp pattern. All matching keys will have their description displayed.
_print_desc : bool, default True
    If True (default) the description(s) will be printed to stdout.
    Otherwise, the description(s) will be returned as a unicode string
    (for testing).

Returns
-------
None by default, the description(s) as a unicode string if _print_desc
is False

Notes
-----
Please reference the :ref:`User Guide <options>` for more information.

The available options with its descriptions:

{opts_desc}
a}  
reset_option(pat)

Reset one or more options to their default value.

Pass "all" as argument to reset all options.

Available options:

{opts_list}

Parameters
----------
pat : str/regex
    If specified only options matching `prefix*` will be reset.
    Note: partial matches are supported for convenience, but unless you
    use the full option name (e.g. x.y.z.option_name), your code may break
    in future versions if new options with similar names are introduced.

Returns
-------
None

Notes
-----
Please reference the :ref:`User Guide <options>` for more information.

The available options with its descriptions:

{opts_desc}
c                   @  s.   e Zd ZdZdddZdddZddd	Zd
S )option_contextaF  
    Context manager to temporarily set options in the `with` statement context.

    You need to invoke as ``option_context(pat, val, [(pat, val), ...])``.

    Examples
    --------
    >>> from pandas import option_context
    >>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
    ...     pass
    r1   r?   c                 G  sL   t |d dkst |dk rtdtt|d d d |dd d | _d S )Nr@   r   z>Need to invoke as option_context(pat, val, [(pat, val), ...]).r2   )r4   rC   rE   rG   ops)ri   rK   r   r   r   rj     s
   (zoption_context.__init__c                 C  s4   dd | j D | _| j D ]\}}t||dd qd S )Nc                 S  s    g | ]\}}|t |d dfqS )Tra   )r>   )rY   r.   rk   r   r   r   rZ          z,option_context.__enter__.<locals>.<listcomp>Tra   )r   undorQ   )ri   r.   rk   r   r   r   	__enter__  s   zoption_context.__enter__c                 G  s,   | j r| j D ]\}}t||dd qd S d S rc   )r   rQ   )ri   rK   r.   rk   r   r   r   __exit__  s
   zoption_context.__exit__Nr1   r?   )r   r   r   r-   rj   r   r   r   r   r   r   r     s
    

r   r   r   r   r    r"   r!   r$   r#   c                 C  sT  ddl }ddl}|  } | tv rtd|  d| tv r$td|  d|r*|| | d}|D ] }td|j	 d |sEt
| d	||rQt
| d
q1t}	d}
t|dd D ]$\}}t|	tsvt|
jd|d| d||	vr~i |	|< |	| }	q^t|	tst|
jd|dd d||	|d < t| ||||dt| < dS )a  
    Register an option in the package-wide pandas config object

    Parameters
    ----------
    key : str
        Fully-qualified key, e.g. "x.y.option - z".
    defval : object
        Default value of the option.
    doc : str
        Description of the option.
    validator : Callable, optional
        Function of a single argument, should raise `ValueError` if
        called with a value which is not a legal value for the option.
    cb
        a function of a single argument "key", which is called
        immediately after an option value is set/reset. key is
        the full name of the option.

    Raises
    ------
    ValueError if `validator` is specified and `defval` is not a valid value.

    r   NOption 'z' has already been registeredz' is a reserved keyrl   ^$z is not a valid identifierz is a python keywordz5Path prefix to option '{option}' is already an option)option)r   r   r    r"   r$   )keywordtokenizelowerr&   r,   r+   splitrematchNamerC   	iskeywordr(   	enumeratern   ro   r   r\   r   )r   r   r    r"   r$   r   r   pathr=   cursorr   ipr   r   r   register_option  s<   





r   r   r   r   c                 C  s6   |   } | tv rtd|  dt| |||t| < dS )a  
    Mark option `key` as deprecated, if code attempts to access this option,
    a warning will be produced, using `msg` if given, or a default message
    if not.
    if `rkey` is given, any access to the key will be re-routed to `rkey`.

    Neither the existence of `key` nor that if `rkey` is checked. If they
    do not exist, any subsequence access will fail as usual, after the
    deprecation warning is given.

    Parameters
    ----------
    key : str
        Name of the option to be deprecated.
        must be a fully-qualified option name (e.g "x.y.z.rkey").
    msg : str, optional
        Warning message to output when the key is referenced.
        if no message is given a default message will be emitted.
    rkey : str, optional
        Name of an option to reroute access to.
        If specified, any referenced `key` will be
        re-routed to `rkey` including set/get/reset.
        rkey must be a fully-qualified option name (e.g "x.y.z.rkey").
        used by the default message if no `msg` is specified.
    removal_ver : str, optional
        Specifies the version in which this option will
        be removed. used by the default message if no `msg` is specified.

    Raises
    ------
    OptionError
        If the specified key has already been deprecated.
    r   z)' has already been defined as deprecated.N)r   r%   r,   r   )r   r   r   r   r   r   r   deprecate_option  s   'r   c                   s8    t v r gS tt  } dkr|S  fdd|D S )zb
    returns a list of keys matching `pat`

    if pat=="all", returns all registered options
    r)   c                   s    g | ]}t  |t jr|qS r   )r   searchIrX   r.   r   r   rZ   Q  r   z#_select_options.<locals>.<listcomp>)r&   sortedr8   )r.   r8   r   r   r   r3   B  s   r3   tuple[dict[str, Any], str]c                 C  s4   |  d}t}|d d D ]}|| }q||d fS )Nrl   r   )r   r(   )r   r   r   r   r   r   r   r;   T  s
   

r;   c                 C  s   |   } | tv S )z4Returns True if the given option has been deprecated)r   r%   r   r   r   r   _is_deprecated\  s   r   c                 C  s$   zt |  }W |S  ty   Y dS w )z
    Retrieves the metadata for a deprecated option, if `key` is deprecated.

    Returns
    -------
    DeprecatedOption (namedtuple) if key is deprecated, None otherwise
    N)r%   rp   r   rf   r   r   r   _get_deprecated_optionb  s   
r   c                 C  s
   t | S )z
    Retrieves the option metadata if `key` is a registered option.

    Returns
    -------
    RegisteredOption (namedtuple) if key is deprecated, None otherwise
    )r&   getr   r   r   r   rH   r  s   
rH   c                 C  s   t | }|r|jp
| S | S )z
    if key id deprecated and a replacement key defined, will return the
    replacement key, otherwise returns `key` as - is
    )r   r   r   r   r   r   r7   }  s   
r7   c                 C  s   t | }|rB|jrtj|jtt d dS d|  d}|jr&|d|j 7 }|jr3|d|j d7 }n|d7 }tj|tt d dS d	S )
z
    Checks if `key` is a deprecated option and if so, prints a warning.

    Returns
    -------
    bool - True if `key` is deprecated, False otherwise.
    )
stacklevel'z' is deprecatedz and will be removed in z, please use 'z
' instead.z, please refrain from using it.TF)r   r   rI   warnFutureWarningr   r   r   )r   rf   r   r   r   r   r5     s$   r5   r=   c                 C  s   t | }t| }|  d}|jr|d|j d7 }n|d7 }|r3|d|j dt| d d7 }|rJ|jp9d}|d	7 }|d
| d7 }|d7 }|S )zCBuilds a formatted description of a registered option and prints it rU   zNo description available.z
    [default: z] [currently: T]rR   z
    (Deprecatedz, use `z
` instead.))	rH   r   r    r\   stripr   r   r>   r   )r=   rP   rf   r^   r   r   r   r   rW     s   

rW   P   r8   rs   widthint_printc           
        s   ddl m} ddlm dfd
d}g }dd t| D }|r(||d|7 }dd | D } |t| dd D ]\ } fddt|D }|| |7 }q8d|}	|r\t|	 dS |	S )z@Builds a concise listing of available options, grouped by prefixr   )groupby)wrapnamer   ksrs   r1   r*   c                   sP   | rd|  d nd}d | |ddd}|r&|d r&| r&|d d	 |d< |S )
Nz- z.[rR   z, z  F)initial_indentsubsequent_indentbreak_long_wordsr   r   )r\   )r   r   pfxls)r   r   r   r   pp  s   zpp_options_list.<locals>.ppc                 S  s   g | ]}| d dk r|qS rl   r   findrY   xr   r   r   rZ         z#pp_options_list.<locals>.<listcomp>rR   c                 S  s   g | ]}| d dkr|qS r   r   r   r   r   r   rZ     r   c                 S  s   | d |  d S Nrl   )rfindr   r   r   r   <lambda>  s    z!pp_options_list.<locals>.<lambda>c                   s    g | ]}|t  d  d qS )r2   N)r4   r   )r=   r   r   rZ     r   rU   N)r   r   r   rs   r1   r*   )	itertoolsr   textwrapr   r   rE   r\   r]   )
r8   r   r   r   r   r   singlesgr   r^   r   )r=   r   r   r   r     s   
r   Generator[None, None, None]c                 #  s\    d fdd}t }t}t}|ta|ta|t a zdV  W |a|a|a dS |a|a|a w )a  
    contextmanager for multiple invocations of API with a common prefix

    supported API functions: (register / get / set )__option

    Warning: This is not thread - safe, and won't work properly if you import
    the API functions into your module using the "from x import y" construct.

    Example
    -------
    import pandas._config.config as cf
    with cf.config_prefix("display.font"):
        cf.register_option("color", "red")
        cf.register_option("size", " 5 pt")
        cf.set_option(size, " 6 pt")
        cf.get_option(size)
        ...

        etc'

    will register options "display.font.color", "display.font.size", set the
    value of "display.font.size"... and so on.
    rw   r   r1   c                   s   d fdd}t t|S )Nr   r   c                   s$    d|  } |g|R i |S r   r   )r   rK   r|   pkey)rw   rg   r   r   inner  s   z*config_prefix.<locals>.wrap.<locals>.innerru   )r   r   )rw   r   rg   )rw   r   r     s   
zconfig_prefix.<locals>.wrapN)rw   r   r1   r   )r   
get_option
set_option)rg   r   _register_optionr>   rQ   r   r   r   config_prefix  s    r   _type	type[Any]Callable[[Any], None]c                   s   d fdd}|S )a  

    Parameters
    ----------
    `_type` - a type to be compared against (e.g. type(x) == `_type`)

    Returns
    -------
    validator - a function of a single argument x , which raises
                ValueError if type(x) is not equal to `_type`

    r1   r?   c                   s    t |  krtd  dd S )NzValue must have type 'r   )typerC   r   r   r   r   r   *  s   zis_type_factory.<locals>.innerNr   r   r   r   r   r   r   is_type_factory  s   r   c                   sH   t  ttfrt  dtt nd  dd fdd}|S )	z

    Parameters
    ----------
    `_type` - the type to be checked against

    Returns
    -------
    validator - a function of a single argument x , which raises
                ValueError if x is not an instance of `_type`

    |r   r1   r?   c                   s   t |  std d S )NzValue must be an instance of )rn   rC   r   r   	type_reprr   r   r   D  s   
z"is_instance_factory.<locals>.innerNr   )rn   tuplerE   r\   mapr   r   r   r   r   is_instance_factory1  s   r   c                   s0   dd D  dd D d fdd}|S )	Nc                 S  s   g | ]}t |r|qS r   callablerY   cr   r   r   rZ   L      z%is_one_of_factory.<locals>.<listcomp>c                 S  s   g | ]}t |s|qS r   r   r   r   r   r   rZ   M  r   r1   r?   c                   s`    vr,t  fddD s.dd D }d|}d| }tr(|d7 }t|d S d S )Nc                 3  s    | ]}| V  qd S r:   r   r   r   r   r   	<genexpr>Q  s    z3is_one_of_factory.<locals>.inner.<locals>.<genexpr>c                 S  rV   r   )r   )rY   lvalr   r   r   rZ   R  r[   z4is_one_of_factory.<locals>.inner.<locals>.<listcomp>r   zValue must be one of z or a callable)anyr\   r4   rC   )r   uvals	pp_valuesr   	callableslegal_valuesr   r   r   O  s   

z is_one_of_factory.<locals>.innerr   r   )r   r   r   r   r   is_one_of_factoryK  s   
r   valuec                 C  s.   | du rdS t | tr| dkrdS d}t|)z
    Verify that value is None or a positive int.

    Parameters
    ----------
    value : None or int
            The `value` to be checked.

    Raises
    ------
    ValueError
        When the value is not None or is a negative integer
    Nr   z+Value must be a nonnegative integer or None)rn   r   rC   )r   r   r   r   r   is_nonnegative_int\  s   
r   c                 C  s   t | stddS )z

    Parameters
    ----------
    `obj` - the object to be checked

    Returns
    -------
    validator - returns True if object is callable
        raises ValueError otherwise.

    zValue must be a callableT)r   rC   )objr   r   r   is_callable~  s   r   )r.   r   r/   r0   r1   r   )F)r.   r   r/   r0   r1   r   r   )rR   T)r.   r   rS   r0   r1   r   )r.   r   r/   r0   r1   r?   )r.   r   )rR   NN)r   r   r   r   r    r   r"   r!   r$   r#   r1   r?   )NNN)
r   r   r   r   r   r   r   r   r1   r?   )r.   r   r1   r*   )r   r   r1   r   )r   r   r1   r0   ru   )r   r   r1   r   )r=   r   r1   r   )r   F)r8   rs   r   r   r   r0   )r1   r   )r   r   r1   r   )r1   r   )r   r   r1   r?   )r1   r0   )Lr-   
__future__r   
contextlibr   r   r   typingr   r   r   r   r	   r
   r   rI   pandas._typingr   r   pandas.util._exceptionsr   r   r   r%   r   r&   r(   r+   AttributeErrorrp   r,   r9   r>   rQ   r_   rb   rd   re   rv   _get_option_tmpl_set_option_tmpl_describe_option_tmpl_reset_option_tmplr   r   reset_optiondescribe_optionoptionsr   r   r   r3   r;   r   r   rH   r7   r5   rW   r   r   r   r   r   r   r   is_intr0   is_boolfloatis_floatr   is_strbytesis_textr   r   r   r   r   <module>   s|    2$		

 
."$"
"


$M
3






&
6


