1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
U
P±d|ã@sÎdZdZddlZddlmmZddlm    Z    m
Z
d!dd„Z dd„Z d    d
„Z d d „Zd"dd„ZGdd„dƒZGdd„dƒZdd„ZGdd„deƒZGdd„deƒZGdd„deƒZGdd„dƒZd#dd „ZdS)$zBA collection of functions designed to help I/O with ascii files.
 
zrestructuredtext enéN)ÚasbytesÚ    asunicodecCs&t|ƒtkr"|dkrd}| |¡}|S)akDecode 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
 
    NÚlatin1)ÚtypeÚbytesÚdecode)ÚlineÚencoding©r
úId:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/lib/_iotools.pyÚ _decode_line s
 
r c    Cs,z |dWnttfk
r&YdSXdS)z2
    Check whether obj behaves like a string.
    ÚFT©Ú    TypeErrorÚ
ValueError©Úobjr
r
r Ú_is_string_like%s
 rc    Cs,z |dWnttfk
r&YdSXdS)z8
    Check whether obj behaves like a bytes object.
    óFTrrr
r
r Ú_is_bytes_like0s
 rcCs(|jpdD]}||jdk    r
dSq
dS)aš
    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
    --------
    >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float)])
    >>> np.lib._iotools.has_nested_fields(dt)
    False
 
    r
NTF)Únames)ÚndtypeÚnamer
r
r Úhas_nested_fields;srFcCsj|j}|dkr2|r*|jgtt |j¡ƒS|jgSg}|D]&}|j|}t|d|ƒ}| |¡q:|SdS)aX
    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
    --------
    >>> 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')]
 
    Nr)    rÚbaseÚintÚnpÚprodÚshapeÚfieldsÚ flatten_dtypeÚextend)rZ flatten_baserÚtypesÚfieldÚinfoZflat_dtr
r
r r Vs!
 r c@sBeZdZdZdd„Zddd„Zd    d
„Zd d „Zd d„Zdd„Z    dS)Ú LineSplittera÷
    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.
 
    cs ‡fdd„S)aÕ
        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.
 
        csdd„ˆ|ƒDƒS)NcSsg|] }| ¡‘qSr
)Ústrip)Ú.0Ú_r
r
r Ú
<listcomp>§sz<LineSplitter.autostrip.<locals>.<lambda>.<locals>.<listcomp>r
)Úinput©Úmethodr
r Ú<lambda>§rz(LineSplitter.autostrip.<locals>.<lambda>r
)Úselfr,r
r+r Ú    autostrip•szLineSplitter.autostripNú#TcCsÐt|ƒ}t|ƒ}||_|dks(t|tƒr8|p.d}|j}npt|dƒr‚|j}t dgt    |ƒ¡}dd„t
|dd…|dd…ƒDƒ}n&t |ƒrœ|j t |ƒ}}n |jd}}||_ |rÀ| |¡|_n||_||_dS)NÚ__iter__rcSsg|]\}}t||ƒ‘qSr
©Úslice)r'ÚiÚjr
r
r r)¸sz)LineSplitter.__init__.<locals>.<listcomp>éÿÿÿÿé)r ÚcommentsÚ
isinstanceÚstrÚ_delimited_splitterÚhasattrÚ_variablewidth_splitterrZcumsumÚlistÚziprÚ_fixedwidth_splitterÚ    delimiterr/Ú    _handymanr    )r.rAr8r/r    rBÚidxr
r
r Ú__init__©s(
&ÿ zLineSplitter.__init__cCs8|jdk    r| |j¡d}| d¡}|s,gS| |j¡S)z2Chop off comments, strip, and split at delimiter. Nrz 
)r8Úsplitr&rA©r.rr
r
r r;Æs 
 
z LineSplitter._delimited_splittercsb|jdk    rˆ |j¡d‰ˆ d¡‰ˆs,gS|j‰‡fdd„tdtˆƒˆƒDƒ}‡fdd„|DƒS)Nrz
csg|]}t||ˆƒ‘qSr
r2©r'r4)Úfixedr
r r)Ösz5LineSplitter._fixedwidth_splitter.<locals>.<listcomp>csg|] }ˆ|‘qSr
r
©r'Ús©rr
r r)×s)r8rEr&rAÚrangeÚlen©r.rZslicesr
)rHrr r@Ïs
 
z!LineSplitter._fixedwidth_splittercs:|jdk    rˆ |j¡d‰ˆs"gS|j}‡fdd„|DƒS)Nrcsg|] }ˆ|‘qSr
r
rIrKr
r r)ßsz8LineSplitter._variablewidth_splitter.<locals>.<listcomp>)r8rErArNr
rKr r=Ùs 
z$LineSplitter._variablewidth_splittercCs| t||jƒ¡S©N)rBr r    rFr
r
r Ú__call__ászLineSplitter.__call__)Nr0TN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__r/rDr;r@r=rPr
r
r
r r%…sÿ
    
r%c@s@eZdZdZdddgZedƒZddd    „Zdd d „Zdd d„Z    dS)Ú NameValidatora"
    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
    --------
    >>> 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~!@#$%^&*()-=+~\|]}[{';: /?.>,<Nr(cCs°|dkr g}| |j¡||_|dkr.|j}nt|ƒ}| d¡||_|dksV|dkrbdd„|_nD|dkst| d¡r€dd„|_n&| d¡r–d    d„|_nd
|}t    |ƒ‚||_
dS) Nú"TcSs|SrOr
©Úxr
r
r r-,rz(NameValidator.__init__.<locals>.<lambda>FÚucSs| ¡SrO)ÚupperrZr
r
r r-.rÚlcSs| ¡SrO)ÚlowerrZr
r
r r-0rz%unrecognized case_sensitive value %s.) r!ÚdefaultexcludelistÚ excludelistÚdefaultdeletecharsÚsetÚaddÚ deletecharsÚcase_converterÚ
startswithrÚ replace_space)r.rareZcase_sensitiverhÚdeleteÚmsgr
r
r rDs$ 
 
 zNameValidator.__init__úf%ic s`|dkr|dkrdSg}t|tƒr(|g}|dk    rlt|ƒ}||krXt|ƒdg||}n||krl|d|…}|j‰|j}|j}|j}g}tƒ}    d}
|D]À} || ƒ     ¡} |r¶|  
d|¡} d  ‡fdd„| Dƒ¡} | dkr||
} | |krú|
d7}
||
} qà|
d7}
n| |kr| d7} |      | d¡} | dkr@|  | d    | ¡n
|  | ¡| d|    | <q–t|ƒS)
a
        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ú csg|]}|ˆkr|‘qSr
r
)r'Úc©rer
r r)lsz*NameValidator.validate.<locals>.<listcomp>r7r(z_%d)r9r:rMr>rerarfrhÚdictr&ÚreplaceÚjoinÚgetÚappendÚtuple) r.rÚ
defaultfmtÚnbfieldsZnbnamesrarfrhZvalidatednamesÚseenZnbemptyÚitemZcntr
rnr Úvalidate7sL
 
 
 
 
 
 
zNameValidator.validatecCs|j|||dS)N)rurv)ry)r.rrurvr
r
r rP}szNameValidator.__call__)NNNr()rkN)rkN)
rQrRrSrTr`rcrbrDryrPr
r
r
r rUås3
ÿ
 
FrUcCs,| ¡}|dkrdS|dkr dStdƒ‚dS)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
    --------
    >>> np.lib._iotools.str2bool('TRUE')
    True
    >>> np.lib._iotools.str2bool('false')
    False
 
    ÚTRUETÚFALSEFzInvalid booleanN)r]r)Úvaluer
r
r Ústr2bools r}c@seZdZdZdS)ÚConverterErrorzR
    Exception raised when an error occurs in a converter for string values.
 
    N©rQrRrSrTr
r
r
r r~¥sr~c@seZdZdZdS)ÚConverterLockErrorzR
    Exception raised when an attempt is made to upgrade a locked converter.
 
    Nrr
r
r
r r€­sr€c@seZdZdZdS)ÚConversionWarningzÞ
    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.
 
    Nrr
r
r
r rµs    rc @sFeZdZdZejedfejedfgZ    e 
ej¡j e 
ej ¡j krRe      ej edf¡e     ejeejfejeejdfejejejfejedfejeejfejeejdfejedfejedfg¡edd„ƒZedd    „ƒZed
d „ƒZed"d d„ƒZ edd„ƒZ!d#dd„Z"dd„Z#dd„Z$dd„Z%dd„Z&dd„Z'dd„Z(d$d d!„Z)d S)%ÚStringConverterab
    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.
 
    Fr6yz???cCs t |¡jS)z(Returns the dtype of the input variable.)rÚarrayÚdtype©ÚclsÚvalr
r
r Ú    _getdtypeszStringConverter._getdtypecCst |¡jjS)z4Returns the type of the dtype of the input variable.)rrƒr„rr…r
r
r Ú _getsubdtype szStringConverter._getsubdtypecCs|jtjkr|S|jS)z9Returns dtype for datetime64 and type of dtype otherwise.)rrZ
datetime64)r†r„r
r
r Ú _dtypeortypes zStringConverter._dtypeortypeNcCsÎt|dƒr(|j d| |¡||f¡dSt|dƒrÊt|dttfƒr`|D]}|j d|¡qHdS|dkrxdgt|ƒ}n$t|ƒ}| dgt|ƒt|ƒ¡t    ||ƒD]"\}}|j d| |¡||f¡q¦dS)aé
        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)
        rPr6Nr1r)
r<Ú_mapperÚinsertr‰r9rtr>rMrsr?)r†ÚfuncÚdefaultr(ZfctZdftr
r
r Úupgrade_mappers
 
zStringConverter.upgrade_mappercCsxt|jƒD]*\}\}}}|j|kr
||||ffSq
t|jƒD].\}\}}}t |j|¡r@||||ffSq@t‚dSrO)Ú    enumerater‹rrZ
issubdtypeÚ LookupError)r†r„r4ÚdeftyperÚ default_defr
r
r Ú_find_map_entryGs
zStringConverter._find_map_entryc
Csìt|ƒ|_|dkr6t|_d|_|p$d|_t d¡}nTzd|_t |¡}Wnrtk
r¼t    |dƒsxd}t|t
|ƒƒ‚||_|dkr®z| d¡}Wnt k
r¬d}YnX|  |¡}YnXz|  |¡\|_\}}}    Wn2tk
r
||_|jd\}}}d|_YnX|dkr|    |_n||_|jdkr6||_|j|jddkrŠt|j
tjƒrftj|_n$t|j
tjƒr€tj|_n
d    d
„|_|dkržd h|_n*t|tƒr´| d ¡}tt|ƒd gƒ|_|j|_| |¡|_
d|_||_dS) NrFÚboolrPzOThe input argument `dtype` is neither a function nor a dtype (got '%s' instead)Ú0r6r7cSs tt|ƒƒSrO)rÚfloatrZr
r
r r-rz*StringConverter.__init__.<locals>.<lambda>r ú,)r•Ú_lockedr}rÚ_statusrŽrr„rr<rrrˆr”r‘r‹Ú
issubclassZuint64Úint64Úmissing_valuesr9r:rErcr>Ú _strict_callÚ_callingfunctionrŠÚ_checkedÚ_initial_default)
r.Z dtype_or_funcrŽrÚlockedr„Úerrmsgr(rr“r
r
r rDUs\
 
 
 
 
 
 
 
 
 
 
 zStringConverter.__init__cCs,z | |¡WStk
r&|jYSXdSrO)rrrŽ©r.r|r
r
r Ú _loose_callžs zStringConverter._loose_callcCs’zH| |¡}|jtkrDztj||jdWntk
rBt‚YnX|WStk
rŒ| ¡|jkr||j    srd|_
|j YStd|ƒ‚YnXdS)N)r„FzCannot convert string '%s') rrrrƒrÚ OverflowErrorrr&rršr rŽ)r.r|Ú    new_valuer
r
r rž¤s
 
 
 
zStringConverter._strict_callcCs
| |¡SrO)rŸr¤r
r
r rP½szStringConverter.__call__cCs„|jrd}t|ƒ‚t|jƒ}|j}||kr8d}t|ƒ‚n||dkrL|d7}|j|\|_|_}||_|jdk    rz|j|_    n||_    dS)Nz*Converter is locked and cannot be upgradedz*Could not find a valid conversion functionr7)
r™r€rMr‹ršr~rrr¡rŽ)r.r£Z
_statusmaxršrŽr
r
r Ú _do_upgradeÀs
 
 
 
zStringConverter._do_upgradecCs>d|_z | |¡WStk
r8| ¡| |¡YSXdS)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.
 
        TN)r ržrr¨Úupgrader¤r
r
r r©Ôs  zStringConverter.upgradecCs^d|_t|dƒs|f}|j}z|D] }||ƒq"Wn&tk
rX| ¡| |¡YnXdS)NTr1)r r<ržrr¨Ú iterupgrade)r.r|ržÚ_mr
r
r rªðs
zStringConverter.iterupgrader c    Csº||_||_|dk    r.||_| | |¡¡|_n@z||p8dƒ}Wnttfk
rZd}YnX| | |¡¡|_|dkr€tƒ|_    n6t
  |¡s|g}t dd„|Dƒƒsªtdƒ‚|j      |¡dS)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Ú1css|]}t|tƒVqdSrO)r9r:)r'Úvr
r
r Ú    <genexpr>1sz)StringConverter.update.<locals>.<genexpr>z)missing_values must be strings or unicode)rr™rŽrŠrˆrrrrcrrÚiterableÚallÚupdate)r.rrŽZ testing_valuerr¢Útesterr
r
r r±üs"
 
 
zStringConverter.update)N)NNNF)NNr F)*rQrRrSrTÚnxZbool_r}Úint_rr‹r„Úitemsizerœrsr!Úfloat64r—ÚnanZ
complex128ÚcomplexZ
longdoubleÚintegerZfloatingZcomplexfloatingZunicode_rZstring_rÚ classmethodrˆr‰rŠrr”rDr¥ržrPr¨r©rªr±r
r
r
r r‚ÂsL/
 
ÿ
 
 
õ
 
 
 (
ÿ
I ÿr‚rkc    Kszzt |¡}Wnrtk
r€tf|Ž}t|ƒ}|dkrHdgt|ƒ}nt|tƒr\| d¡}||||d}t t||d¡}YnöX|dk    rtf|Ž}t|tƒrª| d¡}|j    dkrêt
|j gt|ƒƒ}|||d}t t t ||ƒƒ¡}n||t|j    ƒ|d|_    nt|j    dk    rvtf|Ž}t
dd„tt|j    ƒƒDƒƒ}|j    |krf|d    krf|dgt|j    ƒ|d|_    n||j    |d|_    |S)
a6
    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
    --------
    >>> 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')])
 
    Nr r˜)rvru)Úformatsr)rucss|]}d|VqdS)rkNr
rGr
r
r r®zszeasy_dtype.<locals>.<genexpr>rk)rr„rrUrMr9r:rErorrtrr>r?rL)rrruZvalidationargsryrvr»Znumbered_namesr
r
r Ú
easy_dtype6s>&
 
 
 
 
 
 
 
  ÿ
 
ÿ
r¼)N)F)Nrk)rTZ __docformat__ÚnumpyrZnumpy.core.numericÚcoreÚnumericr³Z numpy.compatrrr rrrr r%rUr}Ú    Exceptionr~r€Ú UserWarningrr‚r¼r
r
r
r Ú<module>s(
 
/`$ v