zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
U
O±ddã @sjdZddgZddlZddlmZddlmZddlmZdd    lm    Z
dd
lm Z m Z m Z dd lmZmZmZmZd d „Zdd„ZGdd„dƒZe
je
je
je
je
je
jiZdZe
jee
j de !d¡de
jee
j"de !d¡de
j#ee
j$de !d¡de
j%ee
j&de !d¡diZ'iZ(dd„Z)iZ*dd„Z+d d!„Z,d"d#„Z-ed$ƒGd%d„dƒƒZ.ed$ƒGd&d„dƒƒZ/dS)'zJMachine limits for Float32 and Float64 and (long double) if available...
 
ÚfinfoÚiinfoéNé)ÚMachAr)Ú
set_module)Únumeric)Ú numerictypes)ÚarrayÚinfÚNaN)Úlog10Úexp2Ú    nextafterÚisnancCs|jdkr| ¡}d|_|S)zfix rank-0 --> rank-1r)r)ÚndimÚcopyÚshape©Úa©rúKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/getlimits.pyÚ_fr0s
rcCs|jdkr| ¡}d|_|S)zfix rank > 0 --> rank-0rr)ÚsizerrrrrrÚ_fr1s
rc@sNeZdZdZddœdd„Zedd„ƒZedd    „ƒZd
d „Zd d „Z    dd„Z
dS)Ú
MachArLikez$ Object to simulate MachAr instance N)Úsmallest_subnormalc    Ks4t||_||_|jd|_|s@t| d¡| d¡|jd|_n||_| |¡|_|_| |¡|_    | |¡|_
|_ | |¡|_ | |¡|_ |_|jd|ƒ|_|j |¡tt|jƒ ƒ|_| | d¡|j ¡|_| |j¡|_| |j    ¡|_| |j ¡|_| |j
¡|_| |j¡|_| |j ¡|_dS)NÚtitlerr©ÚdtypeÚitypeé
)Ú_MACHAR_PARAMSÚparamsÚftyperrÚ_smallest_subnormalÚ_float_to_floatÚepsilonÚepsÚepsnegZxmaxÚhugeZxminÚsmallest_normalÚtinyÚibetaÚ__dict__ÚupdateÚintr Ú    precisionÚ _float_convÚ
resolutionÚ _float_to_strÚ_str_epsÚ _str_epsnegÚ    _str_xminÚ    _str_xmaxÚ_str_resolutionÚ_str_smallest_normal)    Úselfr#r'r(r)r+r,rÚkwargsrrrÚ__init__"s6
 ÿ
   ÿzMachArLike.__init__cCs6|j}| d¡|kr,tjd |j¡tdd| |¡S)a Return the value for the smallest subnormal.
 
        Returns
        -------
        smallest_subnormal : float
            value for the smallest subnormal.
 
        Warns
        -----
        UserWarning
            If the calculated value for the smallest subnormal is zero.
        rz8The value of the smallest subnormal for {} type is zero.é©Ú
stacklevel)r$r#ÚwarningsÚwarnÚformatÚ UserWarningr%©r:Úvaluerrrr>sÿþzMachArLike.smallest_subnormalcCs | |j¡S)z;Return the string representation of the smallest subnormal.)r3r©r:rrrÚ_str_smallest_subnormalVsz"MachArLike._str_smallest_subnormalcCst| |¡ƒS)zConverts float to float.
 
        Parameters
        ----------
        value : float
            value to be converted.
        )rr1rDrrrr%[szMachArLike._float_to_floatcCst|g|jƒS)z€Converts float to conv.
 
        Parameters
        ----------
        value : float
            value to be converted.
        )r    r#rDrrrr1eszMachArLike._float_convcCs|jdtt|ƒd|jƒS)zConverts float to str.
 
        Parameters
        ----------
        value : float
            value to be converted.
        Úfmtr)r"r    rr#rDrrrr3oszMachArLike._float_to_str) Ú__name__Ú
__module__Ú __qualname__Ú__doc__r<ÚpropertyrrGr%r1r3rrrrr sÿ 
 
 
 
rz(numpy {} precision floating point numberz%24.16eÚdouble)rrHrz%15.7eÚsinglez%sz long doublez%12.5eÚhalfcCs |t|<dS©N)Ú _KNOWN_TYPES)ÚmacharZbytepatrrrÚ_register_type™srTcCs¢tj}t|dddddddddt|dƒƒt|dƒƒ|d    ƒ|d
ƒd }t|d ƒ|td<tj}t|d ddddddddt|d ƒƒt|dƒƒ|dddƒt|dƒƒd }t|dƒ|td<tj}d}d}t|dddddddddd|d|||d ƒ|d }t|d!ƒ|td"<tj}t|d#ƒƒ}    t|d$ƒƒ}
t    j
d%d&|d'ƒ|    |
|d ƒ} W5QRXt|d(d#d$d)d*d+dddt|d(ƒƒ|    | |
d } t| d,ƒt| d,ƒ| td<t|d-ƒƒ} t|d$ƒƒ}t    j
d%d&|d'ƒ| ||d ƒ}W5QRXt|d.d-d$d)d/d+dddt|d.ƒƒ| ||d }t|d0ƒ|td1<t |t ƒ|dƒ|d2}t }|t d3dƒƒ}t|d4d5ddd6ddddt|d4ƒƒt|d5ƒƒ|||d7}t|d8ƒt|d9ƒ|td:<dS);Niöÿÿÿiõÿÿÿiòÿÿÿér ér=riàÿg?) ÚmachepÚnegepÚminexpÚmaxexpÚitÚiexpr,ÚirndÚngrdr'r(r)r+sf®iéÿÿÿièÿÿÿi‚ÿÿÿé€éégàÿÿï?sÍÌ̽é g <giÌÿÿÿiËÿÿÿiüÿÿié4é g°<gð?ésš™™™™™¹¿é@iÿÿÿiÀÿÿÚignore)Úallriÿÿÿi@épésš™™™™™™™™™™™™™û¿iÀÿÿÿiÁÿÿÿé?s
ÍÌÌÌÌÌÌÌû¿éPrgi—ÿÿÿi–ÿÿÿéi)rWrXrYrZr[r\r,r]r^r'r(r)r+rsš™™™™™Y<š™™™™™¹¿sš™™™™™¹¿š™™™™™Y<Údd)ÚntypesÚfloat16rr rTÚ    _float_maÚfloat32Úfloat64Ú
longdoublerZerrstaterr
r )Zf16Z
float16_maZf32Z
float32_maZf64Z
epsneg_f64Ztiny_f64Z
float64_maZldZ epsneg_f128Z    tiny_f128Z    huge_f128Z float128_maZ
epsneg_f80Ztiny_f80Zhuge_f80Z
float80_maZhuge_ddZsmallest_normal_ddZsmallest_subnormal_ddZ float_dd_marrrÚ_register_known_typesžs
 
ó
 
 
 
ó
ó
  "
óÿÿ  "
ó
 
 
òÿÿrucCs”t |¡}|dkrtt|ƒƒ‚|dƒ d¡ ¡}d}|tjkrPt |dd…¡}|dkrbt |¡}|dk    rn|St    j
d|›d|›dt dd    t |ƒS)
a€ Get MachAr instance or MachAr-like instance
 
    Get parameters for floating point type, by first trying signatures of
    various known floating point types, then, if none match, attempting to
    identify parameters by analysis.
 
    Parameters
    ----------
    ftype : class
        Numpy floating point type class (e.g. ``np.float64``)
 
    Returns
    -------
    ma_like : instance of :class:`MachAr` or :class:`MachArLike`
        Object giving floating point parameters for `ftype`.
 
    Warns
    -----
    UserWarning
        If the binary signature of the float type is not in the dictionary of
        known float types.
    Nz-0.1ú<r z
Signature z for zz does not match any known type: falling back to type probe function.
This warnings indicates broken support for the dtype!r=r>) r!ÚgetÚ
ValueErrorÚreprZ newbyteorderÚtobytesrortrRr@rArCÚ_discovered_machar)r#r"ÚkeyZma_likerrrÚ _get_machar1s"
 
 
ür}cs>tˆ‰t‡fdd„‡fdd„‡fdd„‡‡fdd„ˆdƒS)zB Create MachAr instance with found information on float types
    cs t|gˆƒSrQ)r    ©Úv©r#rrÚ<lambda>eóz$_discovered_machar.<locals>.<lambda>cst| ˆd¡ƒdS)Nrr)rZastyper~)r"rrrfr‚cstt|ƒdˆƒS)Nr©r    rr~r€rrrgr‚csˆdtt|ƒdˆƒS)NrHrrƒr~©r#r"rrrhr‚r)r!rr€rr„rr{as 
 
 ür{Únumpyc@sXeZdZdZiZdd„Zdd„Zdd„Zdd    „Ze    d
d „ƒZ
e    d d „ƒZ e    dd„ƒZ dS)raá
    finfo(dtype)
 
    Machine limits for floating point types.
 
    Attributes
    ----------
    bits : int
        The number of bits occupied by the type.
    dtype : dtype
        Returns the dtype for which `finfo` returns information. For complex
        input, the returned dtype is the associated ``float*`` dtype for its
        real and complex components.
    eps : float
        The difference between 1.0 and the next smallest representable float
        larger than 1.0. For example, for 64-bit binary floats in the IEEE-754
        standard, ``eps = 2**-52``, approximately 2.22e-16.
    epsneg : float
        The difference between 1.0 and the next smallest representable float
        less than 1.0. For example, for 64-bit binary floats in the IEEE-754
        standard, ``epsneg = 2**-53``, approximately 1.11e-16.
    iexp : int
        The number of bits in the exponent portion of the floating point
        representation.
    machar : MachAr
        The object which calculated these parameters and holds more
        detailed information.
 
        .. deprecated:: 1.22
    machep : int
        The exponent that yields `eps`.
    max : floating point number of the appropriate type
        The largest representable number.
    maxexp : int
        The smallest positive power of the base (2) that causes overflow.
    min : floating point number of the appropriate type
        The smallest representable number, typically ``-max``.
    minexp : int
        The most negative power of the base (2) consistent with there
        being no leading 0's in the mantissa.
    negep : int
        The exponent that yields `epsneg`.
    nexp : int
        The number of bits in the exponent including its sign and bias.
    nmant : int
        The number of bits in the mantissa.
    precision : int
        The approximate number of decimal digits to which this kind of
        float is precise.
    resolution : floating point number of the appropriate type
        The approximate decimal resolution of this type, i.e.,
        ``10**-precision``.
    tiny : float
        An alias for `smallest_normal`, kept for backwards compatibility.
    smallest_normal : float
        The smallest positive floating point number with 1 as leading bit in
        the mantissa following IEEE-754 (see Notes).
    smallest_subnormal : float
        The smallest positive floating point number with 0 as leading bit in
        the mantissa following IEEE-754.
 
    Parameters
    ----------
    dtype : float, dtype, or instance
        Kind of floating point or complex floating point
        data-type about which to get information.
 
    See Also
    --------
    MachAr : The implementation of the tests that produce this information.
    iinfo : The equivalent for integer data types.
    spacing : The distance between a value and the nearest adjacent number
    nextafter : The next floating point value after x1 towards x2
 
    Notes
    -----
    For developers of NumPy: do not instantiate this at the module level.
    The initial calculation of these parameters is expensive and negatively
    impacts import times.  These objects are cached, so calling ``finfo()``
    repeatedly inside your functions is not a problem.
 
    Note that ``smallest_normal`` is not actually the smallest positive
    representable value in a NumPy floating point type. As in the IEEE-754
    standard [1]_, NumPy floating point types make use of subnormal numbers to
    fill the gap between 0 and ``smallest_normal``. However, subnormal numbers
    may have significantly reduced precision [2]_.
 
    This function can also be used for complex data types as well. If used,
    the output will be the same as the corresponding real float type
    (e.g. numpy.finfo(numpy.csingle) is the same as numpy.finfo(numpy.single)).
    However, the output is true for the real and imaginary components.
 
    References
    ----------
    .. [1] IEEE Standard for Floating-Point Arithmetic, IEEE Std 754-2008,
           pp.1-70, 2008, http://www.doi.org/10.1109/IEEESTD.2008.4610935
    .. [2] Wikipedia, "Denormal Numbers",
           https://en.wikipedia.org/wiki/Denormal_number
 
    Examples
    --------
    >>> np.finfo(np.float64).dtype
    dtype('float64')
    >>> np.finfo(np.complex64).dtype
    dtype('float32')
 
    cCszt |¡}Wn"tk
r0t t|ƒ¡}YnX|j |d¡}|dk    rL|S|g}t |¡}||k    rr| |¡|}t|tj    ƒsŠt
d|ƒ‚|j |d¡}|dk    r¤|St|tj ƒsÎt |}||k    rÎ| |¡|}|j |d¡}|dk    rè|St  |¡ |¡}|D]}||j|<qü|S)Nzdata type %r not inexact)rrÚ    TypeErrorÚtypeÚ _finfo_cacherwZ
obj2sctypeÚappendÚ
issubclassZinexactrxZfloatingÚ_convert_to_floatÚobjectÚ__new__Ú_init)ÚclsrÚobjZdtypesZnewdtypeÚdtrrrrÜs:
 
 
 z finfo.__new__cCsôt |¡|_t|ƒ}dD]}t||t||ƒƒqdD]}t||t||ƒjdƒq4|jjd|_|jjd|_    |j     |_
|j jd|_ |j |_ |j|_||_|j ¡|_|j ¡|_|j ¡|_|j ¡|_|j ¡|_|j ¡|_|j ¡|_|S)N)r0r\rZrYrXrW)r2r(rrra)rrr}ÚsetattrÚgetattrÚflatÚitemsizeÚbitsr)ÚmaxÚminr'r\Znexpr[ZnmantÚ_macharr6ÚstripZ    _str_tinyr7Z_str_maxr5r4r8r9rG)r:rrSÚwordrrrrŽýs* 
       z finfo._initcCsd}||jS)Na+Machine parameters for %(dtype)s
---------------------------------------------------------------
precision = %(precision)3s   resolution = %(_str_resolution)s
machep = %(machep)6s   eps =        %(_str_eps)s
negep =  %(negep)6s   epsneg =     %(_str_epsneg)s
minexp = %(minexp)6s   tiny =       %(_str_tiny)s
maxexp = %(maxexp)6s   max =        %(_str_max)s
nexp =   %(nexp)6s   min =        -max
smallest_normal = %(_str_smallest_normal)s   smallest_subnormal = %(_str_smallest_subnormal)s
---------------------------------------------------------------
)r-©r:rHrrrÚ__str__sÿ z finfo.__str__cCs"|jj}|j ¡}||d<d|S)NÚklasszZ%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s))Ú    __class__rIr-r)r:ÚcÚdrrrÚ__repr__'s 
ÿzfinfo.__repr__cCs0t|jjjdƒr"tjdtdd|jjjdS)a7Return the value for the smallest normal.
 
        Returns
        -------
        smallest_normal : float
            Value for the smallest normal.
 
        Warns
        -----
        UserWarning
            If the calculated value for the smallest normal is requested for
            double-double.
        rz;The value of smallest normal is undefined for double doubler=r>)rr™r*r”r@rArCrFrrrr*.sþzfinfo.smallest_normalcCs|jS)aQReturn the value for tiny, alias of smallest_normal.
 
        Returns
        -------
        tiny : float
            Value for the smallest normal, alias of smallest_normal.
 
        Warns
        -----
        UserWarning
            If the calculated value for the smallest normal is requested for
            double-double.
        )r*rFrrrr+Esz
finfo.tinycCstjdtdd|jS)z€The object which calculated these parameters and holds more
        detailed information.
 
        .. deprecated:: 1.22
        z)`finfo.machar` is deprecated (NumPy 1.22)r=r>)r@rAÚDeprecationWarningr™rFrrrrSVs þz finfo.macharN) rIrJrKrLrˆrrŽrr¢rMr*r+rSrrrrrlsl!
 
c@sHeZdZdZiZiZdd„Zedd„ƒZedd„ƒZ    dd    „Z
d
d „Z d S) ra¿
    iinfo(type)
 
    Machine limits for integer types.
 
    Attributes
    ----------
    bits : int
        The number of bits occupied by the type.
    dtype : dtype
        Returns the dtype for which `iinfo` returns information.
    min : int
        The smallest integer expressible by the type.
    max : int
        The largest integer expressible by the type.
 
    Parameters
    ----------
    int_type : integer type, dtype, or instance
        The kind of integer data type to get information about.
 
    See Also
    --------
    finfo : The equivalent for floating point data types.
 
    Examples
    --------
    With types:
 
    >>> ii16 = np.iinfo(np.int16)
    >>> ii16.min
    -32768
    >>> ii16.max
    32767
    >>> ii32 = np.iinfo(np.int32)
    >>> ii32.min
    -2147483648
    >>> ii32.max
    2147483647
 
    With instances:
 
    >>> ii32 = np.iinfo(np.int32(10))
    >>> ii32.min
    -2147483648
    >>> ii32.max
    2147483647
 
    cCs~zt |¡|_Wn$tk
r4t t|ƒ¡|_YnX|jj|_|jjd|_d|j|jf|_|jdkrztd|jfƒ‚dS)Nraz%s%dÚiuzInvalid integer data type %r.)    rrr†r‡Úkindr•r–r|rx)r:Zint_typerrrr<œs
 
ziinfo.__init__cCs\|jdkrdSztj|j}Wn4tk
rRtd|jd> ƒ}|tj|j<YnX|SdS)zMinimum value of given dtype.ÚurrN)r¥rÚ    _min_valsr|ÚKeyErrorr/r–©r:Úvalrrrr˜§s
z    iinfo.mincCsjztj|j}WnTtk
rd|jdkr>td|j>dƒ}ntd|jd>dƒ}|tj|j<YnX|S)zMaximum value of given dtype.r¦r)rÚ    _max_valsr|r¨r¥r/r–r©rrrr—´s
z    iinfo.maxcCsd}||j|j|jdœS)zString representation.z½Machine parameters for %(dtype)s
---------------------------------------------------------------
min = %(min)s
max = %(max)s
---------------------------------------------------------------
©rr˜r—r¬rœrrrrÁsÿz iinfo.__str__cCsd|jj|j|j|jfS)Nz%s(min=%s, max=%s, dtype=%s))rŸrIr˜r—rrFrrrr¢Ìs
ÿziinfo.__repr__N) rIrJrKrLr§r«r<rMr˜r—rr¢rrrrres2 
 
 )0rLÚ__all__r@r™rZ    overridesrÚrrror    r
r Zumathr r rrrrrZcsinglerOZcomplex_Zfloat_Z
clongfloatZ    longfloatr‹Z
_title_fmtrNÚdictÚint64rBÚint32rtZlonglongrPÚint16r!rRrTrqrur}r{rrrrrrÚ<module>sp    [ýýýýýó0 y