Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/numpy/doc/constants.py
7771 views
1
"""
2
=========
3
Constants
4
=========
5
6
.. currentmodule:: numpy
7
8
NumPy includes several constants:
9
10
%(constant_list)s
11
"""
12
#
13
# Note: the docstring is autogenerated.
14
#
15
import re
16
import textwrap
17
18
# Maintain same format as in numpy.add_newdocs
19
constants = []
20
def add_newdoc(module, name, doc):
21
constants.append((name, doc))
22
23
add_newdoc('numpy', 'pi',
24
"""
25
``pi = 3.1415926535897932384626433...``
26
27
References
28
----------
29
https://en.wikipedia.org/wiki/Pi
30
31
""")
32
33
add_newdoc('numpy', 'e',
34
"""
35
Euler's constant, base of natural logarithms, Napier's constant.
36
37
``e = 2.71828182845904523536028747135266249775724709369995...``
38
39
See Also
40
--------
41
exp : Exponential function
42
log : Natural logarithm
43
44
References
45
----------
46
https://en.wikipedia.org/wiki/E_%28mathematical_constant%29
47
48
""")
49
50
add_newdoc('numpy', 'euler_gamma',
51
"""
52
``γ = 0.5772156649015328606065120900824024310421...``
53
54
References
55
----------
56
https://en.wikipedia.org/wiki/Euler-Mascheroni_constant
57
58
""")
59
60
add_newdoc('numpy', 'inf',
61
"""
62
IEEE 754 floating point representation of (positive) infinity.
63
64
Returns
65
-------
66
y : float
67
A floating point representation of positive infinity.
68
69
See Also
70
--------
71
isinf : Shows which elements are positive or negative infinity
72
73
isposinf : Shows which elements are positive infinity
74
75
isneginf : Shows which elements are negative infinity
76
77
isnan : Shows which elements are Not a Number
78
79
isfinite : Shows which elements are finite (not one of Not a Number,
80
positive infinity and negative infinity)
81
82
Notes
83
-----
84
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
85
(IEEE 754). This means that Not a Number is not equivalent to infinity.
86
Also that positive infinity is not equivalent to negative infinity. But
87
infinity is equivalent to positive infinity.
88
89
`Inf`, `Infinity`, `PINF` and `infty` are aliases for `inf`.
90
91
Examples
92
--------
93
>>> np.inf
94
inf
95
>>> np.array([1]) / 0.
96
array([ Inf])
97
98
""")
99
100
add_newdoc('numpy', 'nan',
101
"""
102
IEEE 754 floating point representation of Not a Number (NaN).
103
104
Returns
105
-------
106
y : A floating point representation of Not a Number.
107
108
See Also
109
--------
110
isnan : Shows which elements are Not a Number.
111
112
isfinite : Shows which elements are finite (not one of
113
Not a Number, positive infinity and negative infinity)
114
115
Notes
116
-----
117
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
118
(IEEE 754). This means that Not a Number is not equivalent to infinity.
119
120
`NaN` and `NAN` are aliases of `nan`.
121
122
Examples
123
--------
124
>>> np.nan
125
nan
126
>>> np.log(-1)
127
nan
128
>>> np.log([-1, 1, 2])
129
array([ NaN, 0. , 0.69314718])
130
131
""")
132
133
add_newdoc('numpy', 'newaxis',
134
"""
135
A convenient alias for None, useful for indexing arrays.
136
137
Examples
138
--------
139
>>> newaxis is None
140
True
141
>>> x = np.arange(3)
142
>>> x
143
array([0, 1, 2])
144
>>> x[:, newaxis]
145
array([[0],
146
[1],
147
[2]])
148
>>> x[:, newaxis, newaxis]
149
array([[[0]],
150
[[1]],
151
[[2]]])
152
>>> x[:, newaxis] * x
153
array([[0, 0, 0],
154
[0, 1, 2],
155
[0, 2, 4]])
156
157
Outer product, same as ``outer(x, y)``:
158
159
>>> y = np.arange(3, 6)
160
>>> x[:, newaxis] * y
161
array([[ 0, 0, 0],
162
[ 3, 4, 5],
163
[ 6, 8, 10]])
164
165
``x[newaxis, :]`` is equivalent to ``x[newaxis]`` and ``x[None]``:
166
167
>>> x[newaxis, :].shape
168
(1, 3)
169
>>> x[newaxis].shape
170
(1, 3)
171
>>> x[None].shape
172
(1, 3)
173
>>> x[:, newaxis].shape
174
(3, 1)
175
176
""")
177
178
add_newdoc('numpy', 'NZERO',
179
"""
180
IEEE 754 floating point representation of negative zero.
181
182
Returns
183
-------
184
y : float
185
A floating point representation of negative zero.
186
187
See Also
188
--------
189
PZERO : Defines positive zero.
190
191
isinf : Shows which elements are positive or negative infinity.
192
193
isposinf : Shows which elements are positive infinity.
194
195
isneginf : Shows which elements are negative infinity.
196
197
isnan : Shows which elements are Not a Number.
198
199
isfinite : Shows which elements are finite - not one of
200
Not a Number, positive infinity and negative infinity.
201
202
Notes
203
-----
204
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
205
(IEEE 754). Negative zero is considered to be a finite number.
206
207
Examples
208
--------
209
>>> np.NZERO
210
-0.0
211
>>> np.PZERO
212
0.0
213
214
>>> np.isfinite([np.NZERO])
215
array([ True])
216
>>> np.isnan([np.NZERO])
217
array([False])
218
>>> np.isinf([np.NZERO])
219
array([False])
220
221
""")
222
223
add_newdoc('numpy', 'PZERO',
224
"""
225
IEEE 754 floating point representation of positive zero.
226
227
Returns
228
-------
229
y : float
230
A floating point representation of positive zero.
231
232
See Also
233
--------
234
NZERO : Defines negative zero.
235
236
isinf : Shows which elements are positive or negative infinity.
237
238
isposinf : Shows which elements are positive infinity.
239
240
isneginf : Shows which elements are negative infinity.
241
242
isnan : Shows which elements are Not a Number.
243
244
isfinite : Shows which elements are finite - not one of
245
Not a Number, positive infinity and negative infinity.
246
247
Notes
248
-----
249
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
250
(IEEE 754). Positive zero is considered to be a finite number.
251
252
Examples
253
--------
254
>>> np.PZERO
255
0.0
256
>>> np.NZERO
257
-0.0
258
259
>>> np.isfinite([np.PZERO])
260
array([ True])
261
>>> np.isnan([np.PZERO])
262
array([False])
263
>>> np.isinf([np.PZERO])
264
array([False])
265
266
""")
267
268
add_newdoc('numpy', 'NAN',
269
"""
270
IEEE 754 floating point representation of Not a Number (NaN).
271
272
`NaN` and `NAN` are equivalent definitions of `nan`. Please use
273
`nan` instead of `NAN`.
274
275
See Also
276
--------
277
nan
278
279
""")
280
281
add_newdoc('numpy', 'NaN',
282
"""
283
IEEE 754 floating point representation of Not a Number (NaN).
284
285
`NaN` and `NAN` are equivalent definitions of `nan`. Please use
286
`nan` instead of `NaN`.
287
288
See Also
289
--------
290
nan
291
292
""")
293
294
add_newdoc('numpy', 'NINF',
295
"""
296
IEEE 754 floating point representation of negative infinity.
297
298
Returns
299
-------
300
y : float
301
A floating point representation of negative infinity.
302
303
See Also
304
--------
305
isinf : Shows which elements are positive or negative infinity
306
307
isposinf : Shows which elements are positive infinity
308
309
isneginf : Shows which elements are negative infinity
310
311
isnan : Shows which elements are Not a Number
312
313
isfinite : Shows which elements are finite (not one of Not a Number,
314
positive infinity and negative infinity)
315
316
Notes
317
-----
318
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic
319
(IEEE 754). This means that Not a Number is not equivalent to infinity.
320
Also that positive infinity is not equivalent to negative infinity. But
321
infinity is equivalent to positive infinity.
322
323
Examples
324
--------
325
>>> np.NINF
326
-inf
327
>>> np.log(0)
328
-inf
329
330
""")
331
332
add_newdoc('numpy', 'PINF',
333
"""
334
IEEE 754 floating point representation of (positive) infinity.
335
336
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
337
`inf`. For more details, see `inf`.
338
339
See Also
340
--------
341
inf
342
343
""")
344
345
add_newdoc('numpy', 'infty',
346
"""
347
IEEE 754 floating point representation of (positive) infinity.
348
349
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
350
`inf`. For more details, see `inf`.
351
352
See Also
353
--------
354
inf
355
356
""")
357
358
add_newdoc('numpy', 'Inf',
359
"""
360
IEEE 754 floating point representation of (positive) infinity.
361
362
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
363
`inf`. For more details, see `inf`.
364
365
See Also
366
--------
367
inf
368
369
""")
370
371
add_newdoc('numpy', 'Infinity',
372
"""
373
IEEE 754 floating point representation of (positive) infinity.
374
375
Use `inf` because `Inf`, `Infinity`, `PINF` and `infty` are aliases for
376
`inf`. For more details, see `inf`.
377
378
See Also
379
--------
380
inf
381
382
""")
383
384
385
if __doc__:
386
constants_str = []
387
constants.sort()
388
for name, doc in constants:
389
s = textwrap.dedent(doc).replace("\n", "\n ")
390
391
# Replace sections by rubrics
392
lines = s.split("\n")
393
new_lines = []
394
for line in lines:
395
m = re.match(r'^(\s+)[-=]+\s*$', line)
396
if m and new_lines:
397
prev = textwrap.dedent(new_lines.pop())
398
new_lines.append('%s.. rubric:: %s' % (m.group(1), prev))
399
new_lines.append('')
400
else:
401
new_lines.append(line)
402
s = "\n".join(new_lines)
403
404
# Done.
405
constants_str.append(""".. data:: %s\n %s""" % (name, s))
406
constants_str = "\n".join(constants_str)
407
408
__doc__ = __doc__ % dict(constant_list=constants_str)
409
del constants_str, name, doc
410
del line, lines, new_lines, m, s, prev
411
412
del constants, add_newdoc
413
414