Browse Source

Updated highlights

pull/83/head
Jure Šorn 4 years ago
parent
commit
63a4d1ab7c
4 changed files with 37 additions and 15 deletions
  1. 6
      README.md
  2. 14
      index.html
  3. 23
      parse.js
  4. 9
      pdf/README.md

6
README.md

@ -2618,19 +2618,19 @@ indexes = <array>.argmin(axis)
* **Axis is the index of a dimension that gets collapsed. The leftmost dimension has index 0.**
### Indexing
```bash
```python
<el> = <2d_array>[0, 0] # First element.
<1d_view> = <2d_array>[0] # First row.
<1d_view> = <2d_array>[:, 0] # First column. Also [..., 0].
<3d_view> = <2d_array>[None, :, :] # Expanded by dimension of size 1.
```
```bash
```python
<1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>]
<2d_array> = <2d_array>[<2d_row_indexes>, <2d_column_indexes>]
```
```bash
```python
<2d_bools> = <2d_array> > 0
<1d_array> = <2d_array>[<2d_bools>]
```

14
index.html

@ -957,7 +957,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
</code></pre></div>
<div><h3 id="constructoroverloading">Constructor Overloading</h3><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> &lt;<span class="hljs-title">name</span>&gt;:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a=None)</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a=<span class="hljs-keyword">None</span>)</span>:</span>
self.a = a
</code></pre></div>
@ -2260,16 +2260,16 @@ indexes = &lt;array&gt;.argmin(axis)
<li><strong>Shape is a tuple of dimension sizes.</strong></li>
<li><strong>Axis is the index of a dimension that gets collapsed. The leftmost dimension has index 0.</strong></li>
</ul>
<div><h3 id="indexing">Indexing</h3><pre><code class="bash language-bash hljs">&lt;el&gt; = &lt;2d_array&gt;[0, 0] <span class="hljs-comment"># First element.</span>
&lt;1d_view&gt; = &lt;2d_array&gt;[0] <span class="hljs-comment"># First row.</span>
&lt;1d_view&gt; = &lt;2d_array&gt;[:, 0] <span class="hljs-comment"># First column. Also [..., 0].</span>
&lt;3d_view&gt; = &lt;2d_array&gt;[None, :, :] <span class="hljs-comment"># Expanded by dimension of size 1.</span>
<div><h3 id="indexing">Indexing</h3><pre><code class="python language-python hljs">&lt;el&gt; = &lt;2d_array&gt;[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>] <span class="hljs-comment"># First element.</span>
&lt;1d_view&gt; = &lt;2d_array&gt;[<span class="hljs-number">0</span>] <span class="hljs-comment"># First row.</span>
&lt;1d_view&gt; = &lt;2d_array&gt;[:, <span class="hljs-number">0</span>] <span class="hljs-comment"># First column. Also [..., 0].</span>
&lt;3d_view&gt; = &lt;2d_array&gt;[<span class="hljs-keyword">None</span>, :, :] <span class="hljs-comment"># Expanded by dimension of size 1.</span>
</code></pre></div>
<pre><code class="bash language-bash hljs">&lt;1d_array&gt; = &lt;2d_array&gt;[&lt;1d_row_indexes&gt;, &lt;1d_column_indexes&gt;]
<pre><code class="python language-python hljs">&lt;1d_array&gt; = &lt;2d_array&gt;[&lt;1d_row_indexes&gt;, &lt;1d_column_indexes&gt;]
&lt;2d_array&gt; = &lt;2d_array&gt;[&lt;2d_row_indexes&gt;, &lt;2d_column_indexes&gt;]
</code></pre>
<pre><code class="bash language-bash hljs">&lt;2d_bools&gt; = &lt;2d_array&gt; &gt; 0
<pre><code class="python language-python hljs">&lt;2d_bools&gt; = &lt;2d_array&gt; &gt; <span class="hljs-number">0</span>
&lt;1d_array&gt; = &lt;2d_array&gt;[&lt;2d_bools&gt;]
</code></pre>
<ul>

23
parse.js

@ -37,6 +37,11 @@ const LRU_CACHE =
'<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fib</span><span class="hljs-params">(n)</span>:</span>\n' +
' <span class="hljs-keyword">return</span> n <span class="hljs-keyword">if</span> n &lt; <span class="hljs-number">2</span> <span class="hljs-keyword">else</span> fib(n-<span class="hljs-number">2</span>) + fib(n-<span class="hljs-number">1</span>)\n';
const CONSTRUCTOR_OVERLOADING =
'<span class="hljs-class"><span class="hljs-keyword">class</span> &lt;<span class="hljs-title">name</span>&gt;:</span>\n' +
' <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, a=<span class="hljs-keyword">None</span>)</span>:</span>\n' +
' self.a = a\n';
const DATACLASS =
'<span class="hljs-keyword">from</span> dataclasses <span class="hljs-keyword">import</span> make_dataclass\n' +
'&lt;class&gt; = make_dataclass(<span class="hljs-string">\'&lt;class_name&gt;\'</span>, &lt;coll_of_attribute_names&gt;)\n' +
@ -71,6 +76,20 @@ const PROGRESS_BAR =
'<span class="hljs-meta">... </span> sleep(<span class="hljs-number">1</span>)\n' +
'Processing: 100%|████████████████████| 3/3 [00:03&lt;00:00, 1.00s/it]\n';
const NUMPY_1 =
'&lt;el&gt; = &lt;2d_array&gt;[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>] <span class="hljs-comment"># First element.</span>\n' +
'&lt;1d_view&gt; = &lt;2d_array&gt;[<span class="hljs-number">0</span>] <span class="hljs-comment"># First row.</span>\n' +
'&lt;1d_view&gt; = &lt;2d_array&gt;[:, <span class="hljs-number">0</span>] <span class="hljs-comment"># First column. Also [..., 0].</span>\n' +
'&lt;3d_view&gt; = &lt;2d_array&gt;[<span class="hljs-keyword">None</span>, :, :] <span class="hljs-comment"># Expanded by dimension of size 1.</span>\n';
const NUMPY_2 =
'&lt;1d_array&gt; = &lt;2d_array&gt;[&lt;1d_row_indexes&gt;, &lt;1d_column_indexes&gt;]\n' +
'&lt;2d_array&gt; = &lt;2d_array&gt;[&lt;2d_row_indexes&gt;, &lt;2d_column_indexes&gt;]\n';
const NUMPY_3 =
'&lt;2d_bools&gt; = &lt;2d_array&gt; &gt; <span class="hljs-number">0</span>\n' +
'&lt;1d_array&gt; = &lt;2d_array&gt;[&lt;2d_bools&gt;]\n';
const PYINSTALLER =
'$ pip3 install pyinstaller\n' +
'$ pyinstaller script.py <span class="hljs-comment"># Compiles into \'./dist/script\' directory.</span>\n' +
@ -506,12 +525,16 @@ function fixClasses() {
function fixHighlights() {
$(`code:contains(@lru_cache(maxsize=None))`).html(LRU_CACHE);
$(`code:contains((self, a=None):)`).html(CONSTRUCTOR_OVERLOADING);
$(`code:contains(make_dataclass(\'<class_name>\')`).html(DATACLASS);
$(`code:contains(shutil.copy)`).html(SHUTIL_COPY);
$(`code:contains(os.rename)`).html(OS_RENAME);
$(`code:contains(\'<class_name>\', <parents_tuple>, <attributes_dict>)`).html(TYPE);
$(`code:contains(ValueError: malformed node)`).html(EVAL);
$(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR);
$(`code:contains(<el> = <2d_array>[0, 0])`).html(NUMPY_1);
$(`code:contains(<1d_array> = <2d_array>[<1d_row_indexes>)`).html(NUMPY_2);
$(`code:contains(<2d_bools> = <2d_array> > 0)`).html(NUMPY_3);
$(`code:contains(pip3 install pyinstaller)`).html(PYINSTALLER);
$(`ul:contains(Only available in)`).html(INDEX);
}

9
pdf/README.md

@ -21,11 +21,11 @@ Printing to PDF
### PDF optimized for laser color printing
* Run `./parse.js` again.
* Change all links in text to normal text and add a page number in brackets like that: '(p. <num>)' by running 'pdf/remove_links.py' (Links can be found with this regex: `<strong>.*a href.*</strong>`).
* Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
* Then replace the index and footer with contents of `pdf/index_for_pdf_print.html` file.
* Save.
* Disable internet connection and open the file in Chrome with 'Cache killer' extension enabled.
* Change all links in text to normal text and add a page number in brackets like that: '(p. <num>)' by running 'pdf/remove_links.py' (Links can be found with this regex: `<strong>.*a href.*</strong>`).
* Save and open `index.html` in Chrome.
* Change brightness of elements by right clicking on them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows.
* Change lightness (L) percentage to:
* 0% for the text.
@ -34,8 +34,7 @@ Printing to PDF
* 37% for the red text and function names (they use their own red).
* 60% for the blue text and the text in the contents (it uses its own blue), but leave color of decorators and the `>>>` intact.
* 58% for the comments.
* Individually change brightness of every comment line that starts with: `# $ pip3 install
...` and of comments in basic script template to 57%, by adding `color: hsla(0, 0%, 57%, 1);` to their element.style.
* Individually change brightness of every comment line that starts with: `# $ pip3 install` and of comments in basic script template to 57%, by adding `color: hsla(0, 0%, 57%, 1);` to their element.style.
* Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty).
* Check if plots were rendered correctly.
@ -54,4 +53,4 @@ Adding headers and footers to PDF (the same for both files)
Printing the PDF
----------------
* Open a PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers.
* Open the PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers.
Loading…
Cancel
Save