
    4[g                     *    d dl Zd dlmZ d Z	 	 ddZy)    N)	iskeywordc                 p   | g|z   |z   D ]T  }t        |t              st        d      |j                         st	        d|      t        |      sHt	        d|       t               }||z   D ]D  }|j                  d      rt	        d|      ||v rt	        d|      |j                  |       F y)z
    Ensure that all the given names are valid Python identifiers that
    do not start with '_'.  Also check that there are no duplicates
    among field_names + extra_field_names.
    z,typename and all field names must be stringsz8typename and all field names must be valid identifiers: z2typename and all field names cannot be a keyword: _z-Field names cannot start with an underscore: zDuplicate field name: N)	
isinstancestr	TypeErrorisidentifier
ValueError
_iskeywordset
startswithadd)typenamefield_namesextra_field_namesnameseens        L/var/www/html/bid-api/venv/lib/python3.12/site-packages/scipy/_lib/_bunch.py_validate_namesr      s     
[(+<<$$JKK  " --1H6 7 7d ))-2 3 3 = 5D//??3L $x) * *4<5dX>?? 0    c           
         t        |      dk(  rt        d      |g }t        | ||       t        j                  t        |             } t        t        t        j                  |            }t        t        t        j                  |            }||z   }dj                  |      }dj                  |      }dj                  ddj                  d |D              df      t        j                  }t        t        t        cd| d	| d
| dt        |       d	}~|t        t        t              d|  d}	t        ||	       |	d   }
d|  d| d|
_        |	d   }d|  d| d|_        |	d   }fd}fd}fd}|
|||fD ]  }|  d|j"                   |_         |  d| d||
||||||d	}t'        |      D ]  \  }}|fd}t)        |      ||<    |D ]  }|fd}t)        |      ||<    t+        | t        f|      }|0	 t        j,                  d      j.                  j1                  dd      }|||_        ||
_        |S # t        t        f$ r Y #w xY w)a	  
    Create a namedtuple-like class with additional attributes.

    This function creates a subclass of tuple that acts like a namedtuple
    and that has additional attributes.

    The additional attributes are listed in `extra_field_names`.  The
    values assigned to these attributes are not part of the tuple.

    The reason this function exists is to allow functions in SciPy
    that currently return a tuple or a namedtuple to returned objects
    that have additional attributes, while maintaining backwards
    compatibility.

    This should only be used to enhance *existing* functions in SciPy.
    New functions are free to create objects as return values without
    having to maintain backwards compatibility with an old tuple or
    namedtuple return value.

    Parameters
    ----------
    typename : str
        The name of the type.
    field_names : list of str
        List of names of the values to be stored in the tuple. These names
        will also be attributes of instances, so the values in the tuple
        can be accessed by indexing or as attributes.  At least one name
        is required.  See the Notes for additional restrictions.
    extra_field_names : list of str, optional
        List of names of values that will be stored as attributes of the
        object.  See the notes for additional restrictions.

    Returns
    -------
    cls : type
        The new class.

    Notes
    -----
    There are restrictions on the names that may be used in `field_names`
    and `extra_field_names`:

    * The names must be unique--no duplicates allowed.
    * The names must be valid Python identifiers, and must not begin with
      an underscore.
    * The names must not be Python keywords (e.g. 'def', 'and', etc., are
      not allowed).

    Examples
    --------
    >>> from scipy._lib._bunch import _make_tuple_bunch

    Create a class that acts like a namedtuple with length 2 (with field
    names `x` and `y`) that will also have the attributes `w` and `beta`:

    >>> Result = _make_tuple_bunch('Result', ['x', 'y'], ['w', 'beta'])

    `Result` is the new class.  We call it with keyword arguments to create
    a new instance with given values.

    >>> result1 = Result(x=1, y=2, w=99, beta=0.5)
    >>> result1
    Result(x=1, y=2, w=99, beta=0.5)

    `result1` acts like a tuple of length 2:

    >>> len(result1)
    2
    >>> result1[:]
    (1, 2)

    The values assigned when the instance was created are available as
    attributes:

    >>> result1.y
    2
    >>> result1.beta
    0.5
    r   z*field_names must contain at least one namez,  (c              3   ,   K   | ]  }| d | d  yw)z=%(z)rN ).0r   s     r   	<genexpr>z$_make_tuple_bunch.<locals>.<genexpr>   s     !M94TF#dV2"69s   )zdef __new__(_cls, z0, **extra_fields):
    return _tuple_new(_cls, (z,))

def __init__(self, a  , **extra_fields):
    for key in self._extra_fields:
        if key not in extra_fields:
            raise TypeError("missing keyword argument '%s'" % (key,))
    for key, val in extra_fields.items():
        if key not in self._extra_fields:
            raise TypeError("unexpected keyword argument '%s'" % (key,))
        self.__dict__[key] = val

def __setattr__(self, key, val):
    if key in z:
        raise AttributeError("can't set attribute %r of class %r"
                             % (key, self.__class__.__name__))
    else:
        self.__dict__[key] = val
)r   AttributeErrornamedtuple_)
_tuple_new__builtins____name____new__zCreate new instance of __init__zInstantiate instance of __setattr__c                 X    | j                   j                  | j                         z  z   S )z/Return a nicely formatted representation string)	__class__r#   _asdict)selfrepr_fmts    r   __repr__z#_make_tuple_bunch.<locals>.__repr__   s#    ~~&&DLLN)BBBr   c                 p      | j                   |             }|j                  | j                         |S )z9Return a new dict which maps field names to their values.)_fieldsupdate__dict__)r*   out_dict_zips     r   r)   z"_make_tuple_bunch.<locals>._asdict   s-    Dt,-

4==!
r   c                 ,     |       | j                   fS )z7Return self as a plain tuple.  Used by copy and pickle.r0   )r*   _tuples    r   __getnewargs_ex__z,_make_tuple_bunch.<locals>.__getnewargs_ex__   s    d|T]]**r   .)	__doc__r.   r$   r%   r,   r&   r)   _extra_fieldsr7   c                     | |   S Nr   )r*   indexs     r   _getz_make_tuple_bunch.<locals>._get   s    ;r   c                      | j                   |   S r<   r5   )r*   r   s     r   r>   z_make_tuple_bunch.<locals>._get   s    ==&&r      r#   __main__)lenr
   r   _sysinternr   tuplemapjoinr$   dictzipreprr   r   execr9   r#   __qualname__	enumeratepropertytype	_getframe	f_globalsget
__module__)r   r   r   module	all_namesarg_list	full_list	tuple_news	namespacer$   r%   r&   r,   r)   r7   methodclass_namespacer=   r   r>   resultr2   r6   r3   r+   s                         @@@@r   _make_tuple_bunchr^       s   b ;1EFF Hk+<={{3x=)HDKK56Kc$++/@AB//Iyy%H		)$Iww		!M9!MM H IsE64* &Z (: 
 K ! "	A( 	(!%	5C"E*8*57I 	I	"G/z9+QGGO$H1(1YKqIHM*KC+
 Hg/@A!)
!FOO+<= B Zq1-"*.
O !-t" 	 (	 .
 "  	' (	 " (UHo6F ~	^^A&0044ZLF "#M 
+ 		s   /I II)NN)sysrC   keywordr   r   r   r^   r   r   r   <module>ra      s      +6 @D!Ar   