Browse Source

NumPy

pull/109/merge
Jure Šorn 1 year ago
parent
commit
0f2ae68ac8
2 changed files with 6 additions and 6 deletions
  1. 4
      README.md
  2. 8
      index.html

4
README.md

@ -2662,14 +2662,14 @@ import numpy as np
```python
<array> = np.copy/abs/sqrt/log/int64(<array>) # Returns new array of the same shape.
<array> = <array>.sum/max/mean/argmax/all([axis]) # Passed dimension gets aggregated.
<array> = <array>.sum/max/mean/argmax/all(axis) # Passed dimension gets aggregated.
<array> = np.apply_along_axis(<func>, axis, <array>) # Func can return a scalar or array.
```
```python
<array> = np.concatenate(<list_of_arrays>, axis=0) # Links arrays along first axis (rows).
<array> = np.row_stack/column_stack(<list_of_arrays>) # Treats 1d arrays as rows or columns.
<array> = np.tile(<array>, <int/shape>) # Multiplies passed array.
<array> = np.tile/repeat(<array>, <int/list>) # Tiles array or repeats its elements.
```
* **Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).**
* **Axis is an index of the dimension that gets aggregated. Leftmost dimension has index 0. Summing the RGB image along axis 2 will return a greyscale image with shape (50, 100).**

8
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>April 1, 2023</aside>
<aside>April 2, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2179,12 +2179,12 @@ drawer = cg.output.GraphvizOutput(output_file=filename)
&lt;view&gt; = &lt;array&gt;.transpose() <span class="hljs-comment"># Or: &lt;array&gt;.T</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;array&gt; = np.copy/abs/sqrt/log/int64(&lt;array&gt;) <span class="hljs-comment"># Returns new array of the same shape.</span>
&lt;array&gt; = &lt;array&gt;.sum/max/mean/argmax/all([axis]) <span class="hljs-comment"># Passed dimension gets aggregated.</span>
&lt;array&gt; = &lt;array&gt;.sum/max/mean/argmax/all(axis) <span class="hljs-comment"># Passed dimension gets aggregated.</span>
&lt;array&gt; = np.apply_along_axis(&lt;func&gt;, axis, &lt;array&gt;) <span class="hljs-comment"># Func can return a scalar or array.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;array&gt; = np.concatenate(&lt;list_of_arrays&gt;, axis=<span class="hljs-number">0</span>) <span class="hljs-comment"># Links arrays along first axis (rows).</span>
&lt;array&gt; = np.row_stack/column_stack(&lt;list_of_arrays&gt;) <span class="hljs-comment"># Treats 1d arrays as rows or columns.</span>
&lt;array&gt; = np.tile(&lt;array&gt;, &lt;int/shape&gt;) <span class="hljs-comment"># Multiplies passed array.</span>
&lt;array&gt; = np.tile/repeat(&lt;array&gt;, &lt;int/list&gt;) <span class="hljs-comment"># Tiles array or repeats its elements.</span>
</code></pre>
<ul>
<li><strong>Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).</strong></li>
@ -2935,7 +2935,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer>
<aside>April 1, 2023</aside>
<aside>April 2, 2023</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save