
    (ph                     ,    S SK rS SKJr  S r  SS jrg)    N)	iskeywordc                    U /U-   U-    Hf  n[        U[        5      (       d  [        S5      eUR                  5       (       d  [	        SU< 35      e[        U5      (       d  MY  [	        SU< 35      e   [        5       nX-    HM  nUR                  S5      (       a  [	        SU< 35      eX4;   a  [	        SU< 35      eUR                  U5        MO     g)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        D/var/www/html/venv/lib/python3.13/site-packages/scipy/_lib/_bunch.py_validate_namesr      s     
[(+<<$$$JKK  "" --1H6 7 7d ))-2 3 3 = 5D/??3L $x) * *<5dX>?? 0    c           
        ^^^^ [        U5      S:X  a  [        S5      eUc  / n[        XU5        [        R                  " [        U 5      5      n [        [        [        R                  U5      5      n[        [        [        R                  U5      5      nX-   nSR                  U5      nSR                  U5      nSR                  SSR                  S U 5       5      S45      m[        R                  n[        [        [        smmmSU S	U S
U S[        U5       S3	nAU[        [        [        S9SU  3S.n	[        X5        U	S   n
SU  SU S3U
l        U	S   nSU  SU S3Ul        U	S   nU4S jnUU4S jnU4S jnXX4 H  nU  SUR"                   3Ul        M     U  SU S3UU
UUUUUUS.	n['        U5       H  u  nnU4S jn[)        U5      UU'   M     U H  nU4S jn[)        U5      UU'   M     [+        U [        4U5      nUc1   [        R,                  " S5      R.                  R1                  SS5      nUb  UUl        X:l        U$ ! [        [        4 a     N$f = f)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   0   #    U  H  o S U S3v   M     g7f)z=%(z)rN ).0r   s     r   	<genexpr>$_make_tuple_bunch.<locals>.<genexpr>   s     !M94F#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   > U R                   R                  TU R                  5       -  -   $ )z/Return a nicely formatted representation string)	__class__r$   _asdict)selfrepr_fmts    r   __repr__#_make_tuple_bunch.<locals>.__repr__   s#    ~~&&DLLN)BBBr   c                 p   > T" T" U R                   U 5      5      nUR                  U R                  5        U$ )z9Return a new dict which maps field names to their values.)_fieldsupdate__dict__)r+   out_dict_zips     r   r*   "_make_tuple_bunch.<locals>._asdict   s-    Dt,-

4==!
r   c                 ,   > T" U 5      U R                   4$ )z7Return self as a plain tuple.  Used by copy and pickle.r2   )r+   _tuples    r   __getnewargs_ex__,_make_tuple_bunch.<locals>.__getnewargs_ex__   s    d|T]]**r   .)	__doc__r0   r%   r&   r-   r'   r*   _extra_fieldsr:   c                 
    X   $ Nr   )r+   indexs     r   _get_make_tuple_bunch.<locals>._get   s
    ;r   c                      U R                   U   $ r@   r8   )r+   r   s     r   rB   rC      s    ==&&r      r$   __main__)lenr
   r   _sysinternr   tuplemapjoinr%   dictzipreprr   r    execr=   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*   r:   methodclass_namespacerA   r   rB   resultr4   r9   r5   r,   s                         @@@@r   _make_tuple_bunchrc       s   b ;1EFF H+<={{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 		"G/z9+QGGO$H1(1YKqIHM*KC+
 gA!)
!FOO+<= B Zq1-"*.
O !-t" 	 (	 .
 "  	' (	 " (UHo6F ~	^^A&0044ZLF "#M 
+ 		s   0I I'&I')NN)sysrH   keywordr   r   r   rc   r   r   r   <module>rf      s      +6 @D!Ar   