zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
P±dºPã@s2dZddlZddlZddddddd    d
d d d dg ZddlmmZddlmZm    Z    m
Z
m Z ddl m Z ddlmZddlmZmZejejddZdZe dƒdQdd „ƒZdRdd„Zeeƒejfdd „ƒZdd„Zeeƒdd    „ƒZd d!„Zeeƒd"d„ƒZd#d$„Zeeƒd%d„ƒZeeƒd&d„ƒZ eeƒd'd„ƒZ!eeƒd(d„ƒZ"d)d*„Z#dSd+d,„Z$ee$ƒdTd/d„ƒZ%dUd0d1„Z&ee&ƒdVd3d
„ƒZ'd4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJœZ(e dƒdKd „ƒZ)ej*ej+ej,ej-gdej.ej/ej0ggZ1ej*dej+dej,dLej-dMej.dej/dLej0dMiZ2dNdO„Z3ee3ƒdPd„ƒZ4dS)Wz@Automatically adapted for numpy Sep 19, 2005 by convertcode.py
 
éNÚ iscomplexobjÚ    isrealobjÚimagÚ    iscomplexÚisrealÚ
nan_to_numÚrealÚ real_if_closeÚtypenameÚasfarrayÚ mintypecodeÚ common_type)ÚasarrayÚ
asanyarrayÚisnanÚzeros)Ú
set_module)Ú    overridesé)ÚisneginfÚisposinfÚnumpy)ÚmodulezGDFgdfQqLlIiHhBb?ÚGDFgdfÚdcsNdd„|Dƒ}t‡fdd„|Dƒƒ}|s,|Sd|kr@d|kr@dSt|tjdS)aé
    Return the character for the minimum-size type to which given types can
    be safely cast.
 
    The returned type character must represent the smallest size dtype such
    that an array of the returned type can handle the data from an array of
    all types in `typechars` (or if `typechars` is an array, then its
    dtype.char).
 
    Parameters
    ----------
    typechars : list of str or array_like
        If a list of strings, each string should represent a dtype.
        If array_like, the character representation of the array dtype is used.
    typeset : str or list of str, optional
        The set of characters that the returned character is chosen from.
        The default set is 'GDFgdf'.
    default : str, optional
        The default character, this is returned if none of the characters in
        `typechars` matches a character in `typeset`.
 
    Returns
    -------
    typechar : str
        The character representing the minimum-size type that was found.
 
    See Also
    --------
    dtype, sctype2char, maximum_sctype
 
    Examples
    --------
    >>> np.mintypecode(['d', 'f', 'S'])
    'd'
    >>> x = np.array([1.1, 2-3.j])
    >>> np.mintypecode(x)
    'D'
 
    >>> np.mintypecode('abceh', default='G')
    'G'
 
    css(|] }t|tƒr|pt|ƒjjVqdS©N)Ú
isinstanceÚstrrÚdtypeÚchar©Ú.0Út©r#úKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/lib/type_check.pyÚ    <genexpr>Fsÿzmintypecode.<locals>.<genexpr>c3s|]}|ˆkr|VqdSrr#r ©Útypesetr#r$r%HsÚFrÚD)Úkey)ÚsetÚminÚ_typecodes_by_elsizeÚindex)Z    typecharsr'ÚdefaultZ    typecodesÚ intersectionr#r&r$r s,ÿcCs|fSrr#©Úarr#r#r$Ú_asfarray_dispatcherPsr3cCs t |tj¡stj}t||dS)aJ
    Return an array converted to a float type.
 
    Parameters
    ----------
    a : array_like
        The input array.
    dtype : str or dtype object, optional
        Float type code to coerce input array `a`.  If `dtype` is one of the
        'int' dtypes, it is replaced with float64.
 
    Returns
    -------
    out : ndarray
        The input `a` as a float ndarray.
 
    Examples
    --------
    >>> np.asfarray([2, 3])
    array([2.,  3.])
    >>> np.asfarray([2, 3], dtype='float')
    array([2.,  3.])
    >>> np.asfarray([2, 3], dtype='int8')
    array([2.,  3.])
 
    )r)Ú_nxZ
issubdtypeÚinexactÚfloat_rr1r#r#r$r TscCs|fSrr#©Úvalr#r#r$Ú_real_dispatcherusr9cCs,z|jWStk
r&t|ƒjYSXdS)aÑ
    Return the real part of the complex argument.
 
    Parameters
    ----------
    val : array_like
        Input array.
 
    Returns
    -------
    out : ndarray or scalar
        The real component of the complex argument. If `val` is real, the type
        of `val` is used for the output.  If `val` has complex elements, the
        returned type is float.
 
    See Also
    --------
    real_if_close, imag, angle
 
    Examples
    --------
    >>> a = np.array([1+2j, 3+4j, 5+6j])
    >>> a.real
    array([1.,  3.,  5.])
    >>> a.real = 9
    >>> a
    array([9.+2.j,  9.+4.j,  9.+6.j])
    >>> a.real = np.array([9, 8, 7])
    >>> a
    array([9.+2.j,  8.+4.j,  7.+6.j])
    >>> np.real(1 + 1j)
    1.0
 
    N)rÚAttributeErrorrr7r#r#r$rys$cCs|fSrr#r7r#r#r$Ú_imag_dispatcher£sr;cCs,z|jWStk
r&t|ƒjYSXdS)a
    Return the imaginary part of the complex argument.
 
    Parameters
    ----------
    val : array_like
        Input array.
 
    Returns
    -------
    out : ndarray or scalar
        The imaginary component of the complex argument. If `val` is real,
        the type of `val` is used for the output.  If `val` has complex
        elements, the returned type is float.
 
    See Also
    --------
    real, angle, real_if_close
 
    Examples
    --------
    >>> a = np.array([1+2j, 3+4j, 5+6j])
    >>> a.imag
    array([2.,  4.,  6.])
    >>> a.imag = np.array([8, 10, 12])
    >>> a
    array([1. +8.j,  3.+10.j,  5.+12.j])
    >>> np.imag(1 + 1j)
    1.0
 
    N)rr:rr7r#r#r$r§s!cCs|fSrr#©Úxr#r#r$Ú_is_type_dispatcherÎsr>cCs6t|ƒ}t|jjtjƒr"|jdkSt|jt    ƒ}|dS)aY
    Returns a bool array, where True if input element is complex.
 
    What is tested is whether the input has a non-zero imaginary part, not if
    the input type is complex.
 
    Parameters
    ----------
    x : array_like
        Input array.
 
    Returns
    -------
    out : ndarray of bools
        Output array.
 
    See Also
    --------
    isreal
    iscomplexobj : Return True if x is a complex type or an array of complex
                   numbers.
 
    Examples
    --------
    >>> np.iscomplex([1+1j, 1+0j, 4.5, 3, 2, 2j])
    array([ True, False, False, False, False,  True])
 
    rr#)
rÚ
issubclassrÚtyper4ÚcomplexfloatingrrÚshapeÚbool)r=ZaxÚresr#r#r$rÒs
 
 cCs t|ƒdkS)aÔ
    Returns a bool array, where True if input element is real.
 
    If element has complex type with zero complex part, the return value
    for that element is True.
 
    Parameters
    ----------
    x : array_like
        Input array.
 
    Returns
    -------
    out : ndarray, bool
        Boolean array of same shape as `x`.
 
    Notes
    -----
    `isreal` may behave unexpectedly for string or object arrays (see examples)
 
    See Also
    --------
    iscomplex
    isrealobj : Return True if x is not a complex type.
 
    Examples
    --------
    >>> a = np.array([1+1j, 1+0j, 4.5, 3, 2, 2j], dtype=complex)
    >>> np.isreal(a)
    array([False,  True,  True,  True,  True, False])
 
    The function does not work on string arrays.
 
    >>> a = np.array([2j, "a"], dtype="U")
    >>> np.isreal(a)  # Warns about non-elementwise comparison
    False
 
    Returns True for all elements in input array of ``dtype=object`` even if
    any of the elements is complex.
 
    >>> a = np.array([1, "2", 3+4j], dtype=object)
    >>> np.isreal(a)
    array([ True,  True,  True])
 
    isreal should not be used with object arrays
 
    >>> a = np.array([1+2j, 2+1j], dtype=object)
    >>> np.isreal(a)
    array([ True,  True])
 
    r)rr<r#r#r$r÷s5cCs>z|j}|j}Wn tk
r0t|ƒjj}YnXt|tjƒS)a—
    Check for a complex type or an array of complex numbers.
 
    The type of the input is checked, not the value. Even if the input
    has an imaginary part equal to zero, `iscomplexobj` evaluates to True.
 
    Parameters
    ----------
    x : any
        The input can be of any type and shape.
 
    Returns
    -------
    iscomplexobj : bool
        The return value, True if `x` is of a complex type or has at least
        one complex element.
 
    See Also
    --------
    isrealobj, iscomplex
 
    Examples
    --------
    >>> np.iscomplexobj(1)
    False
    >>> np.iscomplexobj(1+0j)
    True
    >>> np.iscomplexobj([3, 1+0j, True])
    True
 
    )rr@r:rr?r4rA)r=rÚtype_r#r#r$r/s !
cCs
t|ƒ S)aÈ
    Return True if x is a not complex type or an array of complex numbers.
 
    The type of the input is checked, not the value. So even if the input
    has an imaginary part equal to zero, `isrealobj` evaluates to False
    if the data type is complex.
 
    Parameters
    ----------
    x : any
        The input can be of any type and shape.
 
    Returns
    -------
    y : bool
        The return value, False if `x` is of a complex type.
 
    See Also
    --------
    iscomplexobj, isreal
 
    Notes
    -----
    The function is only meant for arrays with numerical values but it
    accepts all other objects. Since it assumes array input, the return
    value of other objects may be True.
 
    >>> np.isrealobj('A string')
    True
    >>> np.isrealobj(False)
    True
    >>> np.isrealobj(None)
    True
 
    Examples
    --------
    >>> np.isrealobj(1)
    True
    >>> np.isrealobj(1+0j)
    False
    >>> np.isrealobj([3, 1+0j, True])
    False
 
    )rr<r#r#r$rXs.cCs"ddlm}| |¡}|j|jfS)Nr©Ú    getlimits)Ú
numpy.corerGÚfinfoÚmaxr,)r"rGÚfr#r#r$Ú
_getmaxminŠs 
rLcCs|fSrr#)r=ÚcopyÚnanÚposinfÚneginfr#r#r$Ú_nan_to_num_dispatchersrQTçcCsêtj|d|d}|jj}|jdk}t|tjƒs>|r:|dS|St|tjƒ}|rZ|j|j    fn|f}t
|jjƒ\}    }
|dk    r||}    |dk    rˆ|}
|D]L} t | ƒ} t | ƒ} t | ƒ}tj| || dtj| |    | dtj| |
|dqŒ|ræ|dS|S)aÀ
    Replace NaN with zero and infinity with large finite numbers (default
    behaviour) or with the numbers defined by the user using the `nan`,
    `posinf` and/or `neginf` keywords.
 
    If `x` is inexact, NaN is replaced by zero or by the user defined value in
    `nan` keyword, infinity is replaced by the largest finite floating point
    values representable by ``x.dtype`` or by the user defined value in
    `posinf` keyword and -infinity is replaced by the most negative finite
    floating point values representable by ``x.dtype`` or by the user defined
    value in `neginf` keyword.
 
    For complex dtypes, the above is applied to each of the real and
    imaginary components of `x` separately.
 
    If `x` is not inexact, then no replacements are made.
 
    Parameters
    ----------
    x : scalar or array_like
        Input data.
    copy : bool, optional
        Whether to create a copy of `x` (True) or to replace values
        in-place (False). The in-place operation only occurs if
        casting to an array does not require a copy.
        Default is True.
 
        .. versionadded:: 1.13
    nan : int, float, optional
        Value to be used to fill NaN values. If no value is passed
        then NaN values will be replaced with 0.0.
 
        .. versionadded:: 1.17
    posinf : int, float, optional
        Value to be used to fill positive infinity values. If no value is
        passed then positive infinity values will be replaced with a very
        large number.
 
        .. versionadded:: 1.17
    neginf : int, float, optional
        Value to be used to fill negative infinity values. If no value is
        passed then negative infinity values will be replaced with a very
        small (or negative) number.
 
        .. versionadded:: 1.17
 
 
 
    Returns
    -------
    out : ndarray
        `x`, with the non-finite values replaced. If `copy` is False, this may
        be `x` itself.
 
    See Also
    --------
    isinf : Shows which elements are positive or negative infinity.
    isneginf : Shows which elements are negative infinity.
    isposinf : Shows which elements are positive infinity.
    isnan : Shows which elements are Not a Number (NaN).
    isfinite : Shows which elements are finite (not NaN, not infinity)
 
    Notes
    -----
    NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
    (IEEE 754). This means that Not a Number is not equivalent to infinity.
 
    Examples
    --------
    >>> np.nan_to_num(np.inf)
    1.7976931348623157e+308
    >>> np.nan_to_num(-np.inf)
    -1.7976931348623157e+308
    >>> np.nan_to_num(np.nan)
    0.0
    >>> x = np.array([np.inf, -np.inf, np.nan, -128, 128])
    >>> np.nan_to_num(x)
    array([ 1.79769313e+308, -1.79769313e+308,  0.00000000e+000, # may vary
           -1.28000000e+002,  1.28000000e+002])
    >>> np.nan_to_num(x, nan=-9999, posinf=33333333, neginf=33333333)
    array([ 3.3333333e+07,  3.3333333e+07, -9.9990000e+03,
           -1.2800000e+02,  1.2800000e+02])
    >>> y = np.array([complex(np.inf, np.nan), np.nan, complex(np.nan, np.inf)])
    array([  1.79769313e+308,  -1.79769313e+308,   0.00000000e+000, # may vary
         -1.28000000e+002,   1.28000000e+002])
    >>> np.nan_to_num(y)
    array([  1.79769313e+308 +0.00000000e+000j, # may vary
             0.00000000e+000 +0.00000000e+000j,
             0.00000000e+000 +1.79769313e+308j])
    >>> np.nan_to_num(y, nan=111111, posinf=222222)
    array([222222.+111111.j, 111111.     +0.j, 111111.+222222.j])
    T)ZsubokrMrr#N)Úwhere)r4Úarrayrr@Úndimr?r5rArrrLrrrZcopyto)r=rMrNrOrPZxtypeZisscalarrÚdestZmaxfZminfrZidx_nanZ
idx_posinfZ
idx_neginfr#r#r$r”s(^
  cCs|fSrr#)r2Útolr#r#r$Ú_real_if_close_dispatcher srXédcCsht|ƒ}t|jjtjƒs|S|dkrHddlm}| |jj¡}|j    |}t 
t  |j ¡|k¡rd|j }|S)a}
    If input is complex with all imaginary parts close to zero, return
    real parts.
 
    "Close to zero" is defined as `tol` * (machine epsilon of the type for
    `a`).
 
    Parameters
    ----------
    a : array_like
        Input array.
    tol : float
        Tolerance in machine epsilons for the complex part of the elements
        in the array.
 
    Returns
    -------
    out : ndarray
        If `a` is real, the type of `a` is used for the output.  If `a`
        has complex elements, the returned type is float.
 
    See Also
    --------
    real, imag, angle
 
    Notes
    -----
    Machine epsilon varies from machine to machine and between data types
    but Python floats on most platforms have a machine epsilon equal to
    2.2204460492503131e-16.  You can use 'np.finfo(float).eps' to print
    out the machine epsilon for floats.
 
    Examples
    --------
    >>> np.finfo(float).eps
    2.2204460492503131e-16 # may vary
 
    >>> np.real_if_close([2.1 + 4e-14j, 5.2 + 3e-15j], tol=1000)
    array([2.1, 5.2])
    >>> np.real_if_close([2.1 + 4e-13j, 5.2 + 3e-15j], tol=1000)
    array([2.1+4.e-13j, 5.2 + 3e-15j])
 
    rrrF)rr?rr@r4rArHrGrIZepsÚallÚabsoluterr)r2rWrGrKr#r#r$r    s- 
Ú    characterrCz signed charz unsigned charÚshortzunsigned shortÚintegerzunsigned integerz long integerzunsigned long integerzlong long integerzunsigned long long integerzsingle precisionzdouble precisionzlong precisionzcomplex single precisionzcomplex double precisionzcomplex long double precisionÚstringÚunicodeZvoidÚobject)ZS1ú?ÚbÚBÚhÚHÚiÚIÚlÚLÚqÚQrKrÚgr(r)ÚGÚSÚUÚVÚOcCst|S)aD
    Return a description for the given data type code.
 
    Parameters
    ----------
    char : str
        Data type code.
 
    Returns
    -------
    out : str
        Description of the input data type code.
 
    See Also
    --------
    dtype, typecodes
 
    Examples
    --------
    >>> typechars = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q',
    ...              'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']
    >>> for typechar in typechars:
    ...     print(typechar, ' : ', np.typename(typechar))
    ...
    S1  :  character
    ?  :  bool
    B  :  unsigned char
    D  :  complex double precision
    G  :  complex long double precision
    F  :  complex single precision
    I  :  unsigned integer
    H  :  unsigned short
    L  :  unsigned long integer
    O  :  object
    Q  :  unsigned long long integer
    S  :  string
    U  :  unicode
    V  :  void
    b  :  signed char
    d  :  double precision
    g  :  long precision
    f  :  single precision
    i  :  integer
    h  :  short
    l  :  long integer
    q  :  long long integer
 
    )Ú _namefromtype)rr#r#r$r
ds2éécGs|Srr#)Úarraysr#r#r$Ú_common_type_dispatcher¦srwcGs~d}d}|D]P}|jj}t|ƒr$d}t|tjƒr6d}nt |d¡}|dkrRtdƒ‚t    ||ƒ}q |rnt
d|St
d|SdS)aË
    Return a scalar type which is common to the input arrays.
 
    The return type will always be an inexact (i.e. floating point) scalar
    type, even if all the arrays are integer arrays. If one of the inputs is
    an integer array, the minimum precision type that is returned is a
    64-bit floating point dtype.
 
    All input arrays except int64 and uint64 can be safely cast to the
    returned dtype without loss of information.
 
    Parameters
    ----------
    array1, array2, ... : ndarrays
        Input arrays.
 
    Returns
    -------
    out : data type code
        Data type code.
 
    See Also
    --------
    dtype, mintypecode
 
    Examples
    --------
    >>> np.common_type(np.arange(2, dtype=np.float32))
    <class 'numpy.float32'>
    >>> np.common_type(np.arange(2, dtype=np.float32), np.arange(2))
    <class 'numpy.float64'>
    >>> np.common_type(np.arange(4), np.array([45, 6.j]), np.array([45.0]))
    <class 'numpy.complex128'>
 
    FrTrtNz+can't get common type for non-numeric arrayr) rr@rr?r4r^Úarray_precisionÚgetÚ    TypeErrorrJÚ
array_type)rvZ
is_complexZ    precisionr2r"Úpr#r#r$r ªs%    )rr)N)NNNN)TrRNN)N)rY)5Ú__doc__Ú    functoolsÚwarningsÚ__all__Znumpy.core.numericÚcoreÚnumericr4rrrrZnumpy.core.overridesrrHrZ    ufunclikerrÚpartialZarray_function_dispatchr-r r3r6r r9rr;rr>rrrrrLrQrrXr    rsr
ZhalfZsingleÚdoubleZ
longdoubleZcsingleZcdoubleZ clongdoubler{rxrwr r#r#r#r$Ú<module>s¼ý  ÿ 5
 
)
&
$
7
(
1
 x
 :ë
6ÿú