Skip to content

Commit 4607f8e

Browse files
committed
added any/all documentation
1 parent f7d86b5 commit 4607f8e

File tree

5 files changed

+289
-41
lines changed

5 files changed

+289
-41
lines changed

docs/manual/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
author = 'Zoltán Vörös'
2828

2929
# The full version, including alpha/beta/rc tags
30-
release = '2.2.0'
30+
release = '2.3.0'
3131

3232

3333
# -- General configuration ---------------------------------------------------

docs/manual/source/numpy-functions.rst

Lines changed: 135 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,141 @@ Numpy functions
55
This section of the manual discusses those functions that were adapted
66
from ``numpy``.
77

8-
1. `numpy.argmax <#argmax>`__
9-
2. `numpy.argmin <#argmin>`__
10-
3. `numpy.argsort <#argsort>`__
11-
4. `numpy.clip <#clip>`__
12-
5. `numpy.convolve <#convolve>`__
13-
6. `numpy.diff <#diff>`__
14-
7. `numpy.equal <#equal>`__
15-
8. `numpy.flip <#flip>`__
16-
9. `numpy.interp <#interp>`__
17-
10. `numpy.isfinite <#isfinite>`__
18-
11. `numpy.isinf <#isinf>`__
19-
12. `numpy.max <#max>`__
20-
13. `numpy.maximum <#maximum>`__
21-
14. `numpy.mean <#mean>`__
22-
15. `numpy.median <#median>`__
23-
16. `numpy.min <#min>`__
24-
17. `numpy.minimum <#minimum>`__
25-
18. `numpy.not_equal <#equal>`__
26-
19. `numpy.polyfit <#polyfit>`__
27-
20. `numpy.polyval <#polyval>`__
28-
21. `numpy.roll <#roll>`__
29-
22. `numpy.sort <#sort>`__
30-
23. `numpy.std <#std>`__
31-
24. `numpy.sum <#sum>`__
32-
25. `numpy.trapz <#trapz>`__
8+
1. `numpy.all <#all>`__
9+
2. `numpy.any <#any>`__
10+
3. `numpy.argmax <#argmax>`__
11+
4. `numpy.argmin <#argmin>`__
12+
5. `numpy.argsort <#argsort>`__
13+
6. `numpy.clip <#clip>`__
14+
7. `numpy.convolve <#convolve>`__
15+
8. `numpy.diff <#diff>`__
16+
9. `numpy.equal <#equal>`__
17+
10. `numpy.flip <#flip>`__
18+
11. `numpy.interp <#interp>`__
19+
12. `numpy.isfinite <#isfinite>`__
20+
13. `numpy.isinf <#isinf>`__
21+
14. `numpy.max <#max>`__
22+
15. `numpy.maximum <#maximum>`__
23+
16. `numpy.mean <#mean>`__
24+
17. `numpy.median <#median>`__
25+
18. `numpy.min <#min>`__
26+
19. `numpy.minimum <#minimum>`__
27+
20. `numpy.not_equal <#equal>`__
28+
21. `numpy.polyfit <#polyfit>`__
29+
22. `numpy.polyval <#polyval>`__
30+
23. `numpy.roll <#roll>`__
31+
24. `numpy.sort <#sort>`__
32+
25. `numpy.std <#std>`__
33+
26. `numpy.sum <#sum>`__
34+
27. `numpy.trapz <#trapz>`__
35+
36+
all
37+
---
38+
39+
``numpy``:
40+
https://numpy.org/doc/stable/reference/generated/numpy.all.html
41+
42+
The function takes one positional, and one keyword argument, the
43+
``axis``, with a default value of ``None``, and tests, whether *all*
44+
array elements along the given axis evaluate to ``True``. If the keyword
45+
argument is ``None``, the flattened array is inspected.
46+
47+
Elements of an array evaluate to ``True``, if they are not equal to
48+
zero, or the Boolean ``False``. The return value if a Boolean
49+
``ndarray``.
50+
51+
.. code::
52+
53+
# code to be run in micropython
54+
55+
from ulab import numpy as np
56+
57+
a = np.array(range(12)).reshape((3, 4))
58+
59+
print('\na:\n', a)
60+
61+
b = np.all(a)
62+
print('\nall of the flattened array:\n', b)
63+
64+
c = np.all(a, axis=0)
65+
print('\nall of a along 0th axis:\n', c)
66+
67+
d = np.all(a, axis=1)
68+
print('\nall of a along 1st axis:\n', d)
69+
70+
.. parsed-literal::
71+
72+
73+
a:
74+
array([[0.0, 1.0, 2.0, 3.0],
75+
[4.0, 5.0, 6.0, 7.0],
76+
[8.0, 9.0, 10.0, 11.0]], dtype=float64)
77+
78+
all of the flattened array:
79+
False
80+
81+
all of a along 0th axis:
82+
array([False, True, True, True], dtype=bool)
83+
84+
all of a along 1st axis:
85+
array([False, True, True], dtype=bool)
86+
87+
88+
89+
90+
any
91+
---
92+
93+
``numpy``:
94+
https://numpy.org/doc/stable/reference/generated/numpy.any.html
95+
96+
The function takes one positional, and one keyword argument, the
97+
``axis``, with a default value of ``None``, and tests, whether *any*
98+
array element along the given axis evaluates to ``True``. If the keyword
99+
argument is ``None``, the flattened array is inspected.
100+
101+
Elements of an array evaluate to ``True``, if they are not equal to
102+
zero, or the Boolean ``False``. The return value if a Boolean
103+
``ndarray``.
104+
105+
.. code::
106+
107+
# code to be run in micropython
108+
109+
from ulab import numpy as np
110+
111+
a = np.array(range(12)).reshape((3, 4))
112+
113+
print('\na:\n', a)
114+
115+
b = np.any(a)
116+
print('\nany of the flattened array:\n', b)
117+
118+
c = np.any(a, axis=0)
119+
print('\nany of a along 0th axis:\n', c)
120+
121+
d = np.any(a, axis=1)
122+
print('\nany of a along 1st axis:\n', d)
123+
124+
.. parsed-literal::
125+
126+
127+
a:
128+
array([[0.0, 1.0, 2.0, 3.0],
129+
[4.0, 5.0, 6.0, 7.0],
130+
[8.0, 9.0, 10.0, 11.0]], dtype=float64)
131+
132+
any of the flattened array:
133+
True
134+
135+
any of a along 0th axis:
136+
array([True, True, True, True], dtype=bool)
137+
138+
any of a along 1st axis:
139+
array([True, True, True], dtype=bool)
140+
141+
142+
33143
34144
argmax
35145
------

docs/numpy-functions.ipynb

Lines changed: 140 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"execution_count": 1,
66
"metadata": {
77
"ExecuteTime": {
8-
"end_time": "2021-01-29T21:13:12.041212Z",
9-
"start_time": "2021-01-29T21:13:10.138344Z"
8+
"end_time": "2021-02-08T16:48:29.443204Z",
9+
"start_time": "2021-02-08T16:48:29.246310Z"
1010
}
1111
},
1212
"outputs": [
@@ -31,11 +31,11 @@
3131
},
3232
{
3333
"cell_type": "code",
34-
"execution_count": 3,
34+
"execution_count": 2,
3535
"metadata": {
3636
"ExecuteTime": {
37-
"end_time": "2021-01-29T21:24:02.702618Z",
38-
"start_time": "2021-01-29T21:24:02.696753Z"
37+
"end_time": "2021-02-08T16:48:32.087734Z",
38+
"start_time": "2021-02-08T16:48:32.079158Z"
3939
}
4040
},
4141
"outputs": [],
@@ -49,11 +49,11 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": 4,
52+
"execution_count": 3,
5353
"metadata": {
5454
"ExecuteTime": {
55-
"end_time": "2021-01-29T21:24:05.849861Z",
56-
"start_time": "2021-01-29T21:24:05.796272Z"
55+
"end_time": "2021-02-08T16:48:34.384905Z",
56+
"start_time": "2021-02-08T16:48:34.333699Z"
5757
}
5858
},
5959
"outputs": [],
@@ -232,6 +232,8 @@
232232
"source": [
233233
"This section of the manual discusses those functions that were adapted from `numpy`.\n",
234234
"\n",
235+
"1. [numpy.all](#all)\n",
236+
"1. [numpy.any](#any)\n",
235237
"1. [numpy.argmax](#argmax)\n",
236238
"1. [numpy.argmin](#argmin)\n",
237239
"1. [numpy.argsort](#argsort)\n",
@@ -259,6 +261,136 @@
259261
"1. [numpy.trapz](#trapz)"
260262
]
261263
},
264+
{
265+
"cell_type": "markdown",
266+
"metadata": {},
267+
"source": [
268+
"## all\n",
269+
"\n",
270+
"`numpy`: https://numpy.org/doc/stable/reference/generated/numpy.all.html\n",
271+
"\n",
272+
"The function takes one positional, and one keyword argument, the `axis`, with a default value of `None`, and tests, whether *all* array elements along the given axis evaluate to `True`. If the keyword argument is `None`, the flattened array is inspected. \n",
273+
"\n",
274+
"Elements of an array evaluate to `True`, if they are not equal to zero, or the Boolean `False`. The return value if a Boolean `ndarray`."
275+
]
276+
},
277+
{
278+
"cell_type": "code",
279+
"execution_count": 5,
280+
"metadata": {
281+
"ExecuteTime": {
282+
"end_time": "2021-02-08T16:54:57.117630Z",
283+
"start_time": "2021-02-08T16:54:57.105337Z"
284+
}
285+
},
286+
"outputs": [
287+
{
288+
"name": "stdout",
289+
"output_type": "stream",
290+
"text": [
291+
"\n",
292+
"a:\n",
293+
" array([[0.0, 1.0, 2.0, 3.0],\n",
294+
" [4.0, 5.0, 6.0, 7.0],\n",
295+
" [8.0, 9.0, 10.0, 11.0]], dtype=float64)\n",
296+
"\n",
297+
"all of the flattened array:\n",
298+
" False\n",
299+
"\n",
300+
"all of a along 0th axis:\n",
301+
" array([False, True, True, True], dtype=bool)\n",
302+
"\n",
303+
"all of a along 1st axis:\n",
304+
" array([False, True, True], dtype=bool)\n",
305+
"\n",
306+
"\n"
307+
]
308+
}
309+
],
310+
"source": [
311+
"%%micropython -unix 1\n",
312+
"\n",
313+
"from ulab import numpy as np\n",
314+
"\n",
315+
"a = np.array(range(12)).reshape((3, 4))\n",
316+
"\n",
317+
"print('\\na:\\n', a)\n",
318+
"\n",
319+
"b = np.all(a)\n",
320+
"print('\\nall of the flattened array:\\n', b)\n",
321+
"\n",
322+
"c = np.all(a, axis=0)\n",
323+
"print('\\nall of a along 0th axis:\\n', c)\n",
324+
"\n",
325+
"d = np.all(a, axis=1)\n",
326+
"print('\\nall of a along 1st axis:\\n', d)"
327+
]
328+
},
329+
{
330+
"cell_type": "markdown",
331+
"metadata": {},
332+
"source": [
333+
"## any\n",
334+
"\n",
335+
"`numpy`: https://numpy.org/doc/stable/reference/generated/numpy.any.html\n",
336+
"\n",
337+
"The function takes one positional, and one keyword argument, the `axis`, with a default value of `None`, and tests, whether *any* array element along the given axis evaluates to `True`. If the keyword argument is `None`, the flattened array is inspected. \n",
338+
"\n",
339+
"Elements of an array evaluate to `True`, if they are not equal to zero, or the Boolean `False`. The return value if a Boolean `ndarray`."
340+
]
341+
},
342+
{
343+
"cell_type": "code",
344+
"execution_count": 4,
345+
"metadata": {
346+
"ExecuteTime": {
347+
"end_time": "2021-02-08T16:54:14.704132Z",
348+
"start_time": "2021-02-08T16:54:14.693700Z"
349+
}
350+
},
351+
"outputs": [
352+
{
353+
"name": "stdout",
354+
"output_type": "stream",
355+
"text": [
356+
"\n",
357+
"a:\n",
358+
" array([[0.0, 1.0, 2.0, 3.0],\n",
359+
" [4.0, 5.0, 6.0, 7.0],\n",
360+
" [8.0, 9.0, 10.0, 11.0]], dtype=float64)\n",
361+
"\n",
362+
"any of the flattened array:\n",
363+
" True\n",
364+
"\n",
365+
"any of a along 0th axis:\n",
366+
" array([True, True, True, True], dtype=bool)\n",
367+
"\n",
368+
"any of a along 1st axis:\n",
369+
" array([True, True, True], dtype=bool)\n",
370+
"\n",
371+
"\n"
372+
]
373+
}
374+
],
375+
"source": [
376+
"%%micropython -unix 1\n",
377+
"\n",
378+
"from ulab import numpy as np\n",
379+
"\n",
380+
"a = np.array(range(12)).reshape((3, 4))\n",
381+
"\n",
382+
"print('\\na:\\n', a)\n",
383+
"\n",
384+
"b = np.any(a)\n",
385+
"print('\\nany of the flattened array:\\n', b)\n",
386+
"\n",
387+
"c = np.any(a, axis=0)\n",
388+
"print('\\nany of a along 0th axis:\\n', c)\n",
389+
"\n",
390+
"d = np.any(a, axis=1)\n",
391+
"print('\\nany of a along 1st axis:\\n', d)"
392+
]
393+
},
262394
{
263395
"cell_type": "markdown",
264396
"metadata": {},

docs/ulab-change-log.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Mon, 8 Feb 2021
2+
3+
version 2.3.0
4+
5+
added any and all functions
6+
17
Fri, 29 Jan 2021
28

39
version 2.2.0

0 commit comments

Comments
 (0)