
    Гh                     \   S r SSKrSSKrSSKJr  SSKJr  SSKJrJ	r	J
r
JrJrJr  SSKJr  SSKJrJrJrJr  SSSSSS	.S
\\   S\\   S\\   S\\   S\\   S\	\/\4   4S jjr\" SSS9S\SS4S j5       r\" SSS9S\
\\4   4S j5       r\\" SSSSS9S\S\S   4S j5       5       rg)z Global configuration for XGBoost    N)contextmanager)wraps)AnyCallableDictIteratorOptionalcast   )_F)_LIB_check_callc_strpy_str)header
extra_note
parametersreturnssee_alsor   r   r   r   r   returnc           	         ^ ^^^^^^^ SmSmS[         [           S[        4S jmS[        S[        4UUUU UUUU4S jjnU$ )a  Decorator to format docstring for config functions.

Parameters
----------
header: str
    An introducion to the function
extra_note: str
    Additional notes
parameters: str
    Parameters of the function
returns: str
    Return value
see_also: str
    Related functions
a  
    {header}

    Global configuration consists of a collection of parameters that can be applied in the
    global scope. See :ref:`global_config` for the full list of parameters supported in
    the global configuration.

    {extra_note}

    .. versionadded:: 1.4.0
    af  
    Example
    -------

    .. code-block:: python

        import xgboost as xgb

        # Show all messages, including ones pertaining to debugging
        xgb.set_config(verbosity=2)

        # Get current value of global configuration
        # This is a dict containing all parameters in the global configuration,
        # including 'verbosity'
        config = xgb.get_config()
        assert config['verbosity'] == 2

        # Example of using the context manager xgb.config_context().
        # The context manager will restore the previous value of the global
        # configuration upon exiting.
        with xgb.config_context(verbosity=0):
            # Suppress warning caused by model generated with XGBoost version < 1.0.0
            bst = xgb.Booster(model_file='./old_model.bin')
        assert xgb.get_config()['verbosity'] == 2  # old value restored

    Nested configuration context is also supported:

    Example
    -------

    .. code-block:: python

        with xgb.config_context(verbosity=3):
            assert xgb.get_config()["verbosity"] == 3
            with xgb.config_context(verbosity=2):
                assert xgb.get_config()["verbosity"] == 2

        xgb.set_config(verbosity=2)
        assert xgb.get_config()["verbosity"] == 2
        with xgb.config_context(verbosity=3):
            assert xgb.get_config()["verbosity"] == 3
    valuer   c                     U c  S$ U $ )N  )r   s    aC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\xgboost/config.pynone_to_strconfig_doc.<locals>.none_to_str\   s    ]r--    funcc                    >^  TR                  T" T5      T" T5      S9T" T5      -   T" T5      -   T" T5      -   T" T	5      -   T l        [        T 5      S[        S[        S[        4U 4S jj5       n[	        [
        U5      $ )N)r   r   argskwargsr   c                     > T" U 0 UD6$ Nr   )r"   r#   r    s     r   wrap6config_doc.<locals>.config_doc_decorator.<locals>.wrapj   s    (((r   )format__doc__r   r   r
   r   )
r    r&   common_exampledoc_templater   r   r   r   r   r   s
   ` r   config_doc_decorator(config_doc.<locals>.config_doc_decorator_   s    "6*{:7N    *%& '"	#
 .)* (#$ 	 
t	) 	)s 	)s 	) 
	) B~r   )r	   strr   )	r   r   r   r   r   r,   r*   r+   r   s	   ````` @@@r   
config_docr/      sI    0
L)NV.8C= .S .2 "  "  r   z#
    Set global configuration.
    z
    Parameters
    ----------
    new_config: Dict[str, Any]
        Keyword arguments representing the parameters and their values
            )r   r   
new_configc                      0 nU R                  5        H  u  p#Uc  M
  X1U'   M     [        R                  " U5      n[        [        R
                  " [        U5      5      5        g r%   )itemsjsondumpsr   r   XGBSetGlobalConfigr   )r0   not_nonekvconfigs        r   
set_configr:   s   sQ     H  "=QK # ZZ!F''f67r   z9
    Get current values of the global configuration.
    zu
    Returns
    -------
    args: Dict[str, Any]
        The list of global parameters and their values
            )r   r   c                      [         R                  " 5       n [        [        R                  " [         R
                  " U 5      5      5        U R                  nU(       d   e[        R                  " [        U5      5      nU$ r%   )
ctypesc_char_pr   r   XGBGetGlobalConfigbyrefr   r3   loadsr   )
config_strr   r9   s      r   
get_configrB      sU     "J''Z(@ABEL5ZZu&FMr   z;
    Context manager for global XGBoost configuration.
    z
    .. note::

        All settings, not just those presently modified, will be returned to their
        previous values when the context manager is exited. This is not thread-safe.
            z
    See Also
    --------
    set_config: Set global XGBoost configuration
    get_config: Get current values of the global configuration
            )r   r   r   r   c               +      #    [        5       R                  5       n[        S0 U D6   S v   [        S0 UD6  g ! [        S0 UD6  f = f7f)Nr   )rB   copyr:   )r0   
old_configs     r   config_contextrF      s@     2 ""$J! Z 
 Z s   $A7 AAA)r)   r<   r3   
contextlibr   	functoolsr   typingr   r   r   r   r	   r
   _typingr   corer   r   r   r   r.   r/   r:   rB   rF   r   r   r   <module>rL      sD   &   %  @ @  2 2
 ! $ $!"c SMc  c  	c 
 c]c  smc  rdBhc L 	
8S 8T 8
8 	
DcN 
 !.! !$ !/ 0!r   