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