
    Khx                         S r SrSSKrSSKJs  Jr  SSKJ	r	J
r
  SS jrS rS rS rSS	 jr " S
 S5      r " S S5      rS r " S S\5      r " S S\5      r " S S\5      r " S S5      rSS jrg)zBA collection of functions designed to help I/O with ascii files.

zrestructuredtext en    N)asbytes	asunicodec                 V    [        U 5      [        L a  Uc  SnU R                  U5      n U $ )a;  Decode bytes from binary input streams.

Defaults to decoding from 'latin1'. That differs from the behavior of
np.compat.asunicode that decodes from 'ascii'.

Parameters
----------
line : str or bytes
     Line to be decoded.
encoding : str
     Encoding used to decode `line`.

Returns
-------
decoded_line : str

latin1)typebytesdecode)lineencodings     D/var/www/html/env/lib/python3.13/site-packages/numpy/lib/_iotools.py_decode_liner      s.    $ DzUH{{8$K    c                 <     U S-     g! [         [        4 a     gf = f)z*
Check whether obj behaves like a string.
 FT	TypeError
ValueErrorobjs    r   _is_string_liker   %   s,    b  z"     c                 <     U S-     g! [         [        4 a     gf = f)z0
Check whether obj behaves like a bytes object.
r   FTr   r   s    r   _is_bytes_liker   0   s,    c	  z" r   c                 T   ^  [        U 4S jT R                  =(       d    S 5       5      $ )au  
Returns whether one or several fields of a dtype are nested.

Parameters
----------
ndtype : dtype
    Data-type of a structured array.

Raises
------
AttributeError
    If `ndtype` does not have a `names` attribute.

Examples
--------
>>> import numpy as np
>>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)])
>>> np.lib._iotools.has_nested_fields(dt)
False

c              3   F   >#    U  H  nTU   R                   S Lv   M     g 7fN)names).0namendtypes     r   	<genexpr>$has_nested_fields.<locals>.<genexpr>Q   s"     M:L$vd|!!-:Ls   ! )anyr   )r    s   `r   has_nested_fieldsr%   ;   s"    , M&,,:L":LMMMr   c                 .   U R                   nUcK  U(       a7  U R                  /[        [        R                  " U R
                  5      5      -  $ U R                  /$ / nU H2  nU R                  U   n[        US   U5      nUR                  U5        M4     U$ )a  
Unpack a structured data-type by collapsing nested fields and/or fields
with a shape.

Note that the field names are lost.

Parameters
----------
ndtype : dtype
    The datatype to collapse
flatten_base : bool, optional
   If True, transform a field with a shape into several fields. Default is
   False.

Examples
--------
>>> import numpy as np
>>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float),
...                ('block', int, (2, 3))])
>>> np.lib._iotools.flatten_dtype(dt)
[dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64')]
>>> np.lib._iotools.flatten_dtype(dt, flatten_base=True)
[dtype('S4'),
 dtype('float64'),
 dtype('float64'),
 dtype('int64'),
 dtype('int64'),
 dtype('int64'),
 dtype('int64'),
 dtype('int64'),
 dtype('int64')]

r   )	r   baseintnpprodshapefieldsflatten_dtypeextend)r    flatten_baser   typesfieldinfoflat_dts          r   r-   r-   T   s    D LLE}KK=3rwwv||'<#===}E=='D#DG\:GLL!  r   c                   D    \ rS rSrSrS r  SS jrS rS rS r	S	 r
S
rg)LineSplitter   a  
Object to split a string at a given delimiter or at given places.

Parameters
----------
delimiter : str, int, or sequence of ints, optional
    If a string, character used to delimit consecutive fields.
    If an integer or a sequence of integers, width(s) of each field.
comments : str, optional
    Character used to mark the beginning of a comment. Default is '#'.
autostrip : bool, optional
    Whether to strip each individual field. Default is True.

c                    ^ U4S j$ )am  
Wrapper to strip each member of the output of `method`.

Parameters
----------
method : function
    Function that takes a single argument and returns a sequence of
    strings.

Returns
-------
wrapped : function
    The result of wrapping `method`. `wrapped` takes a single input
    argument and returns a list of strings that are stripped of
    white-space.

c                 Z   > T" U 5       Vs/ s H  oR                  5       PM     sn$ s  snf r   )strip)input_methods     r   <lambda>(LineSplitter.autostrip.<locals>.<lambda>   s    ?Aggi??s   (r#   )selfr<   s    `r   	autostripLineSplitter.autostrip   s    $ @?r   Nc                 P   [        U5      n[        U5      nX l        Ub  [        U[        5      (       a  U=(       d    S nU R                  nO[        US5      (       a_  U R                  n[        R                  " S/[        U5      -   5      n[        US S USS  5       VVs/ s H  u  px[        Xx5      PM     nnnO4[        U5      (       a  U R                  [        U5      pOU R                  S pXl        U(       a  U R                  U5      U l        OXPl        X@l        g s  snnf )N__iter__r      )r   comments
isinstancestr_delimited_splitterhasattr_variablewidth_splitterr)   cumsumlistzipslicer(   _fixedwidth_splitter	delimiterr@   	_handymanr   )	r?   rQ   rF   r@   r   rR   idxijs	            r   __init__LineSplitter.__init__   s     +	)  *Y"<"<!)TI00IY
++44I))QC$y/12C36s3BxQR3IJ3I!q3IIJI^^--s9~ " '+&>&>	"!^^I6DN&N  Ks   "D"c                     U R                   b  UR                  U R                   5      S   nUR                  S5      nU(       d  / $ UR                  U R                  5      $ )z2Chop off comments, strip, and split at delimiter. r   z 
)rF   splitr9   rQ   r?   r
   s     r   rI    LineSplitter._delimited_splitter   sL    ==$::dmm,Q/Dzz'"Izz$..))r   c                 F   U R                   b  UR                  U R                   5      S   nUR                  S5      nU(       d  / $ U R                  n[	        S[        U5      U5       Vs/ s H  n[        X3U-   5      PM     nnU Vs/ s H  oQU   PM	     sn$ s  snf s  snf )Nr   z
)rF   rY   r9   rQ   rangelenrO   )r?   r
   fixedrT   slicesss         r   rP   !LineSplitter._fixedwidth_splitter   s    ==$::dmm,Q/Dzz&!I/4QD	5/IJ/I!%u9%/IJ!'(AQ(( K(s   *BBc                     U R                   b  UR                  U R                   5      S   nU(       d  / $ U R                  nU Vs/ s H  o1U   PM	     sn$ s  snf )Nr   )rF   rY   rQ   )r?   r
   r`   ra   s       r   rK   $LineSplitter._variablewidth_splitter   sN    ==$::dmm,Q/DI!'(AQ(((s   Ac                 J    U R                  [        XR                  5      5      $ r   )rR   r   r   rZ   s     r   __call__LineSplitter.__call__   s    ~~l4?@@r   )rR   rF   rQ   r   )N#TN)__name__
__module____qualname____firstlineno____doc__r@   rV   rI   rP   rK   rf   __static_attributes__r#   r   r   r5   r5      s1    @( @D!:*))Ar   r5   c                   R    \ rS rSrSr/ SQr\" S5      r  S
S jrSS jr	SS jr
S	rg)NameValidator   a  
Object to validate a list of strings to use as field names.

The strings are stripped of any non alphanumeric character, and spaces
are replaced by '_'. During instantiation, the user can define a list
of names to exclude, as well as a list of invalid characters. Names in
the exclusion list are appended a '_' character.

Once an instance has been created, it can be called with a list of
names, and a list of valid names will be created.  The `__call__`
method accepts an optional keyword "default" that sets the default name
in case of ambiguity. By default this is 'f', so that names will
default to `f0`, `f1`, etc.

Parameters
----------
excludelist : sequence, optional
    A list of names to exclude. This list is appended to the default
    list ['return', 'file', 'print']. Excluded names are appended an
    underscore: for example, `file` becomes `file_` if supplied.
deletechars : str, optional
    A string combining invalid characters that must be deleted from the
    names.
case_sensitive : {True, False, 'upper', 'lower'}, optional
    * If True, field names are case-sensitive.
    * If False or 'upper', field names are converted to upper case.
    * If 'lower', field names are converted to lower case.

    The default value is True.
replace_space : '_', optional
    Character(s) used in replacement of white spaces.

Notes
-----
Calling an instance of `NameValidator` is the same as calling its
method `validate`.

Examples
--------
>>> import numpy as np
>>> validator = np.lib._iotools.NameValidator()
>>> validator(['file', 'field2', 'with space', 'CaSe'])
('file_', 'field2', 'with_space', 'CaSe')

>>> validator = np.lib._iotools.NameValidator(excludelist=['excl'],
...                                           deletechars='q',
...                                           case_sensitive=False)
>>> validator(['excl', 'field2', 'no_q', 'with space', 'CaSe'])
('EXCL', 'FIELD2', 'NO_Q', 'WITH_SPACE', 'CASE')

)returnfileprintz~!@#$%^&*()-=+~\|]}[{';: /?.>,<Nc                    Uc  / nUR                  U R                  5        Xl        Uc  U R                  nO[	        U5      nUR                  S5        XPl        Ub  USL a	  S U l        OSUSL d  UR                  S5      (       a	  S U l        O/UR                  S5      (       a	  S U l        OS	U-  n[        U5      eX@l
        g )
N"Tc                     U $ r   r#   xs    r   r=   (NameValidator.__init__.<locals>.<lambda>,  s    Ar   Fuc                 "    U R                  5       $ r   )upperrx   s    r   r=   rz   .  
    AGGIr   lc                 "    U R                  5       $ r   )lowerrx   s    r   r=   rz   0  r~   r   z%unrecognized case_sensitive value %s.)r.   defaultexcludelistexcludelistdefaultdeletecharssetadddeletecharscase_converter
startswithr   replace_space)r?   r   r   case_sensitiver   deletemsgs          r   rV   NameValidator.__init__  s     K4223&,,F%F

3!"$(>"-D%.*C*CC*H*H"5D&&s++"5D9NJCS/!*r   c                    Uc  Uc  g/ n[        U[        5      (       a  U/nUb/  [        U5      nXC:  a  [        U5      S/X4-
  -  -   nO
XC:  a  USU nU R                  nU R
                  nU R                  nU R                  n/ n	[        5       n
SnU H  nU" U5      R                  5       nU(       a  UR                  SU5      nSR                  U Vs/ s H  oU;  d  M
  UPM     sn5      nUS:X  a  X+-  nX;   a  US-  nX+-  nX;   a  M  US-  nO
X;   a  US-  nU
R                  US5      nUS:  a  U	R                  USU-  -   5        OU	R                  U5        US-   X'   M     [        U	5      $ s  snf )ac  
Validate a list of strings as field names for a structured array.

Parameters
----------
names : sequence of str
    Strings to be validated.
defaultfmt : str, optional
    Default format string, used if validating a given string
    reduces its length to zero.
nbfields : integer, optional
    Final number of validated names, used to expand or shrink the
    initial list of names.

Returns
-------
validatednames : list of str
    The list of validated field names.

Notes
-----
A `NameValidator` instance can be called directly, which is the
same as calling `validate`. For examples, see `NameValidator`.

Nr   r    rE   r;   z_%d)rG   rH   r^   rM   r   r   r   r   dictr9   replacejoingetappendtuple)r?   r   
defaultfmtnbfieldsnbnamesr   r   r   r   validatednamesseennbemptyitemccnts                  r   validateNameValidator.validate7  s   6 M EeS!!IE%jG"Urdh.@&AA$ix(&&&&,,**vD!$'--/D||C777tDt!/CAtDEDrz!+mqLG%/D m 1$((4#CQw%%dUS[&89%%d+qDJ% & ^$$ Es   	E5
"E5
c                 "    U R                  XUS9$ )N)r   r   )r   )r?   r   r   r   s       r   rf   NameValidator.__call__}  s    }}UH}MMr   )r   r   r   r   )NNNr;   f%iN)ri   rj   rk   rl   rm   r   r   r   rV   r   rf   rn   r#   r   r   rp   rp      s4    2h 5CD5947+6D%LNr   rp   c                 T    U R                  5       n U S:X  a  gU S:X  a  g[        S5      e)a  
Tries to transform a string supposed to represent a boolean to a boolean.

Parameters
----------
value : str
    The string that is transformed to a boolean.

Returns
-------
boolval : bool
    The boolean representation of `value`.

Raises
------
ValueError
    If the string is not 'True' or 'False' (case independent)

Examples
--------
>>> import numpy as np
>>> np.lib._iotools.str2bool('TRUE')
True
>>> np.lib._iotools.str2bool('false')
False

TRUETFALSEFzInvalid boolean)r}   r   )values    r   str2boolr     s0    8 KKME	'	*++r   c                       \ rS rSrSrSrg)ConverterErrori  zJ
Exception raised when an error occurs in a converter for string values.

r#   Nri   rj   rk   rl   rm   rn   r#   r   r   r   r          	r   r   c                       \ rS rSrSrSrg)ConverterLockErrori  zJ
Exception raised when an attempt is made to upgrade a locked converter.

r#   Nr   r#   r   r   r   r     r   r   r   c                       \ rS rSrSrSrg)ConversionWarningi  z
Warning issued when a string converter has a problem.

Notes
-----
In `genfromtxt` a `ConversionWarning` is issued if raising exceptions
is explicitly suppressed with the "invalid_raise" keyword.

r#   Nr   r#   r   r   r   r     s     	r   r   c                   F   \ rS rSrSr\R                  \S4\R                  \	S4/r
\R                  " \R                  5      R                  \R                  " \R                  5      R                  :  a  \
R                  \R                  \	S45        \
R                  \R                   \\R$                  4\R&                  \\R$                  S-   4\R*                  \R*                  \R$                  4\R,                  \	S4\R.                  \\R$                  4\R0                  \\R$                  S-   4\R2                  \S4\R6                  \S4/5        \S 5       r\S 5       r\S	 5       r \SS j5       r!\S 5       r"  SS jr#S r$S r%S r&S r'S r(S r)  SS jr*Sr+g
)StringConverteri  a  
Factory class for function transforming a string into another object
(int, float).

After initialization, an instance can be called to transform a string
into another object. If the string is recognized as representing a
missing value, a default value is returned.

Attributes
----------
func : function
    Function used for the conversion.
default : any
    Default value to return when the input corresponds to a missing
    value.
type : type
    Type of the output.
_status : int
    Integer representing the order of the conversion.
_mapper : sequence of tuples
    Sequence of tuples (dtype, function, default value) to evaluate in
    order.
_locked : bool
    Holds `locked` parameter.

Parameters
----------
dtype_or_func : {None, dtype, function}, optional
    If a `dtype`, specifies the input data type, used to define a basic
    function and a default value for missing data. For example, when
    `dtype` is float, the `func` attribute is set to `float` and the
    default value to `np.nan`.  If a function, this function is used to
    convert a string to another object. In this case, it is recommended
    to give an associated default value as input.
default : any, optional
    Value to return by default, that is, when the string to be
    converted is flagged as missing. If not given, `StringConverter`
    tries to supply a reasonable default value.
missing_values : {None, sequence of str}, optional
    ``None`` or sequence of strings indicating a missing value. If ``None``
    then missing values are indicated by empty entries. The default is
    ``None``.
locked : bool, optional
    Whether the StringConverter should be locked to prevent automatic
    upgrade or not. Default is False.

FrD   y                z???c                 B    [         R                  " U5      R                  $ )z(Returns the dtype of the input variable.)r)   arraydtypeclsvals     r   	_getdtypeStringConverter._getdtype	  s     xx}"""r   c                 V    [         R                  " U5      R                  R                  $ )z4Returns the type of the dtype of the input variable.)r)   r   r   r   r   s     r   _getsubdtypeStringConverter._getsubdtype  s     xx}""'''r   c                 Z    UR                   [        R                  :X  a  U$ UR                   $ )z9Returns dtype for datetime64 and type of dtype otherwise.)r   r)   
datetime64)r   r   s     r   _dtypeortypeStringConverter._dtypeortype  s#     ::&Lzzr   Nc                 >   [        U5      (       a.  U R                  R                  SU R                  U5      X45        g[	        US5      (       a  [        US   [        [        45      (       a&  U H  nU R                  R                  SU5        M!     gUc  S/[        U5      -  nO5[        U5      nUR                  S/[        U5      [        U5      -
  -  5        [        X5       H2  u  pEU R                  R                  SU R                  U5      XE45        M4     gg)aY  
Upgrade the mapper of a StringConverter by adding a new function and
its corresponding default.

The input function (or sequence of functions) and its associated
default value (if any) is inserted in penultimate position of the
mapper.  The corresponding type is estimated from the dtype of the
default value.

Parameters
----------
func : var
    Function, or sequence of functions

Examples
--------
>>> import dateutil.parser
>>> import datetime
>>> dateparser = dateutil.parser.parse
>>> defaultdate = datetime.date(2000, 1, 1)
>>> StringConverter.upgrade_mapper(dateparser, default=defaultdate)
rD   NrC   r   )callable_mapperinsertr   rJ   rG   r   rM   r^   r   rN   )r   funcdefaultr;   fctdfts         r   upgrade_mapperStringConverter.upgrade_mapper  s    2 D>>KKrC$4$4W$=t#MNT:&&$q'E4=11AKK&&r1- &3t9,w-vTS\)ABC.""2(8(8(=s'HI / 'r   c                    [        U R                  5       H   u  nu  p4nUR                  U:X  d  M  X#XE44s  $    [        U R                  5       H6  u  nu  p4n[        R                  " UR                  U5      (       d  M1  X#XE44s  $    [
        er   )	enumerater   r   r)   
issubdtypeLookupError)r   r   rT   deftyper   default_defs         r   _find_map_entryStringConverter._find_map_entryH  s     09/E+A+{zzW$D666 0F
 09/E+A+{}}UZZ11D666 0F r   c                     [        U5      U l        Uc:  [        U l        SU l        U=(       d    SU l        [        R                  " S5      nGO S U l        [        R                  " U5      n U R                  U5      u  U l        u  pxn	Uc  Xl        OX l         U R                  c  Xl        U R                  U R                  S   S   :X  a  [!        UR                  [        R"                  5      (       a  [        R"                  U l        OG[!        UR                  [        R$                  5      (       a  [        R$                  U l        OS U l        Uc	  S	1U l        OC[)        U[*        5      (       a  UR-                  S
5      n[/        [1        U5      S	/-   5      U l        U R2                  U l        U R7                  U5      U l
        SU l        X l        g ! [         al    [        U5      (       d  Sn[        U[        U5      -  5      eXl        Uc%   U R                  S5      nO! [         a    S n Of = fU R                  U5      n GNf = f! [         a#    X l        U R                  S   u  pxnSU l         GNf = f)Nr   FboolzOThe input argument `dtype` is neither a function nor a dtype (got '%s' instead)0rD   rE   c                 *    [        [        U 5      5      $ r   )r(   floatrx   s    r   r=   *StringConverter.__init__.<locals>.<lambda>  s    #eAh-r   r   ,)r   _lockedr   r   _statusr   r)   r   r   r   r   r   r   r   r   r   
issubclassuint64int64missing_valuesrG   rH   rY   r   rM   _strict_call_callingfunctionr   _checked_initial_default)
r?   dtype_or_funcr   r   lockedr   errmsgr;   r   r   s
             r   rV   StringConverter.__init__V  s    F|  DIDL"+eDLHHV$E0 	/&+7;7K7KE7R44q ?#.L#*L yy  	 yyDLLOA..ejj"))44 "		DI

BHH55 "DI 7DI!#%$D.#..!/!5!5c!:"%d>&:bT&A"BD $ 1 1%%e,	 'q  0..IF#FT--@$@AA)	 ?'"&))C.% '"&'w/0(  !&!\\"-
 	!sH   G -I <IH&%I&H52I4H55II)I=<I=c                 ^     U R                  U5      $ ! [         a    U R                  s $ f = fr   )r   r   r   r?   r   s     r   _loose_callStringConverter._loose_call  s/    	 99U## 	 <<	 s    ,,c                 z    U R                  U5      nU R                   [        L a!   [        R                  " XR                  S9  U$ U$ ! [
         a    [        ef = f! [         aS    UR                  5       U R                  ;   a&  U R                  (       d  SU l
        U R                  s $ [        SU-  5      ef = f)N)r   FzCannot convert string '%s')r   r(   r)   r   r   OverflowErrorr   r9   r   r   r   r   )r?   r   	new_values      r   r   StringConverter._strict_call  s    	C 		%(I
 yyC%HHU))4
 9	 % %$$%  	C{{} 3 33||$)DM||#9EABB	Cs/   $A A	 A A 	AA AB:+B:c                 $    U R                  U5      $ r   )r   r   s     r   rf   StringConverter.__call__  s    $$U++r   c                 P   U R                   (       a  Sn[        U5      e[        U R                  5      nU R                  nX2:X  a  Sn[        U5      eX2S-
  :  a  US-  nU R                  U   u  U l        U l        nX0l        U R                  b  U R                  U l	        g X@l	        g )Nz*Converter is locked and cannot be upgradedz*Could not find a valid conversion functionrE   )
r   r   r^   r   r   r   r   r   r   r   )r?   r   
_statusmaxr   r   s        r   _do_upgradeStringConverter._do_upgrade  s    <<AF$V,,&
,, AF ((A~%qLG(,W(=%	49g  ,00DL"Lr   c                     SU l          U R                  U5      $ ! [         a$    U R                  5         U R	                  U5      s $ f = f)a  
Find the best converter for a given string, and return the result.

The supplied string `value` is converted by testing different
converters in order. First the `func` method of the
`StringConverter` instance is tried, if this fails other available
converters are tried.  The order in which these other converters
are tried is determined by the `_status` attribute of the instance.

Parameters
----------
value : str
    The string to convert.

Returns
-------
out : any
    The result of converting `value` with the appropriate converter.

T)r   r   r   r   upgrader   s     r   r   StringConverter.upgrade  sK    * 	'$$U++ 	'<<&&	's    +AAc                     SU l         [        US5      (       d  U4nU R                  n U H  nU" U5        M     g ! [         a$    U R	                  5         U R                  U5         g f = f)NTrC   )r   rJ   r   r   r   iterupgrade)r?   r   r   _ms       r   r   StringConverter.iterupgrade  sh    uj))HE((	$R   	$U#	$s   ; +A)(A)c                    Xl         XPl        Ub,  X l        U R                  U R	                  U5      5      U l        O7 U" U=(       d    S5      nU R                  U R	                  U5      5      U l        Uc  [        5       U l	        g[        R                  " U5      (       d  U/n[        S U 5       5      (       d  [        S5      eU R                  R                  U5        g! [        [        4 a    Sn Nf = f)a  
Set StringConverter attributes directly.

Parameters
----------
func : function
    Conversion function.
default : any, optional
    Value to return by default, that is, when the string to be
    converted is flagged as missing. If not given,
    `StringConverter` tries to supply a reasonable default value.
testing_value : str, optional
    A string representing a standard input value of the converter.
    This string is used to help defining a reasonable default
    value.
missing_values : {sequence of str, None}, optional
    Sequence of strings indicating a missing value. If ``None``, then
    the existing `missing_values` are cleared. The default is ``''``.
locked : bool, optional
    Whether the StringConverter should be locked to prevent
    automatic upgrade or not. Default is False.

Notes
-----
`update` takes the same parameters as the constructor of
`StringConverter`, except that `func` does not accept a `dtype`
whereas `dtype_or_func` in the constructor does.

N1c              3   B   #    U  H  n[        U[        5      v   M     g 7fr   )rG   rH   )r   vs     r   r!   )StringConverter.update.<locals>.<genexpr>2  s     B>az!S))>s   z)missing_values must be strings or unicode)r   r   r   r   r   r   r   r   r   r   r)   iterableallupdate)r?   r   r   testing_valuer   r   testers          r   r  StringConverter.update  s    > 	 "L))$..*ABDIm2s3 ))$..*@ADI ! #&%D;;~.."0!1B>BBB KLL&&~6 z* s   C" "C76C7)	r   r   r   r   r   r   r   r   r   r   )NNNF)NNr   F),ri   rj   rk   rl   rm   nxr   r   int_r(   r   r   itemsizer   r   r.   float64r   nan
complex128complex
longdoubleintegerfloatingcomplexfloatingstr_r   bytes_r   classmethodr   r   r   r   r   rV   r   r   rf   r   r   r   r  rn   r#   r   r   r   r     s   .^ 5)b!$G
 
xx!!BHHRXX$6$?$??#r*+NNRZZ/]]GRVVb[9]]BMM266: ZZb)[[%0''"&&2+> WWi/YY/  # # ( ( 	 	 &J &JP   IMG(R C2,#('8
$ 8<).77r   r   c                     [         R                  " U 5      n Ub  [        S0 UD6n[        U[        5      (       a  UR                  S5      nU R                  cR  [        U R                  /[        U5      -  5      nU" XS9n[         R                  " [        [        X5      5      5      n U $ U" U[        U R                  5      US9U l         U $ U R                  b  [        S0 UD6n[        S [        [        U R                  5      5       5       5      nU R                  U:X  a+  US:w  a%  U" S/[        U R                  5      -  US9U l        U $ U" U R                  US9U l        U $ ! [         aw    [        S0 UD6n[        U 5      nUc  S/[        U 5      -  nO&[        U[        5      (       a  UR                  S5      nU" XUS9n[         R                  " [        XS95      n  U $ f = f)	a  
Convenience function to create a `np.dtype` object.

The function processes the input `dtype` and matches it with the given
names.

Parameters
----------
ndtype : var
    Definition of the dtype. Can be any string or dictionary recognized
    by the `np.dtype` function, or a sequence of types.
names : str or sequence, optional
    Sequence of strings to use as field names for a structured dtype.
    For convenience, `names` can be a string of a comma-separated list
    of names.
defaultfmt : str, optional
    Format string used to define missing names, such as ``"f%i"``
    (default) or ``"fields_%02i"``.
validationargs : optional
    A series of optional arguments used to initialize a
    `NameValidator`.

Examples
--------
>>> import numpy as np
>>> np.lib._iotools.easy_dtype(float)
dtype('float64')
>>> np.lib._iotools.easy_dtype("i4, f8")
dtype([('f0', '<i4'), ('f1', '<f8')])
>>> np.lib._iotools.easy_dtype("i4, f8", defaultfmt="field_%03i")
dtype([('field_000', '<i4'), ('field_001', '<f8')])

>>> np.lib._iotools.easy_dtype((int, float, float), names="a,b,c")
dtype([('a', '<i8'), ('b', '<f8'), ('c', '<f8')])
>>> np.lib._iotools.easy_dtype(float, names="a,b,c")
dtype([('a', '<f8'), ('b', '<f8'), ('c', '<f8')])

r   )r   )r   r   c              3   ,   #    U  H
  nS U-  v   M     g7fr   r#   )r   rT   s     r   r!   easy_dtype.<locals>.<genexpr>|  s     "O6N5196Ns   r   r   )formatsr   r#   )r)   r   rp   rG   rH   rY   r   r   r   r^   rM   rN   r]   r   r   )r    r   r   validationargsr   r  numbered_namesr   s           r   
easy_dtyper  7  s   N$M&! $6~6H%%%C(||#E
 :; >$s5':";<  M  (FLL8I3= ? M \\%$6~6H""OeC<M6N"OON/jE6I's6<</@(@3= ?
 M  (LMG  = 2>2v;=D3v;&Es##KK$EjI$v;<6 MG=s   E' 'A=G('G(r   )F)Nr   )rm   __docformat__numpyr)   numpy._core.numeric_corenumericr  numpy._utilsr   r   r   r   r   r%   r-   r5   rp   r   	Exceptionr   r   UserWarningr   r   r  r#   r   r   <module>r(     s    &      +4N2-`]A ]A@ZN ZNz",J	Y 		 	
	 
	q7 q7hLr   