From 63a4d1ab7c3ec7b0ae430404bb571ec176512511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 2 Dec 2020 13:32:06 +0100 Subject: [PATCH] Updated highlights --- README.md | 6 +++--- index.html | 14 +++++++------- parse.js | 23 +++++++++++++++++++++++ pdf/README.md | 9 ++++----- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e31cbb9..09654b0 100644 --- a/README.md +++ b/README.md @@ -2618,19 +2618,19 @@ indexes = .argmin(axis) * **Axis is the index of a dimension that gets collapsed. The leftmost dimension has index 0.** ### Indexing -```bash +```python = <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>] ``` diff --git a/index.html b/index.html index 1a5e062..cb5d091 100644 --- a/index.html +++ b/index.html @@ -957,7 +957,7 @@ Z = dataclasses.make_dataclass('Z', [

Constructor Overloading

class <name>:
-    def __init__(self, a=None):
+    def __init__(self, a=None):
         self.a = a
 
@@ -2260,16 +2260,16 @@ indexes = <array>.argmin(axis)
  • Shape is a tuple of dimension sizes.
  • Axis is the index of a dimension that gets collapsed. The leftmost dimension has index 0.
  • -

    Indexing

    <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.
    +

    Indexing

    <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.
     
    -
    <1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>]
    +
    <1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>]
     <2d_array> = <2d_array>[<2d_row_indexes>, <2d_column_indexes>]
     
    -
    <2d_bools> = <2d_array> > 0
    +
    <2d_bools> = <2d_array> > 0
     <1d_array> = <2d_array>[<2d_bools>]
     
      diff --git a/parse.js b/parse.js index 2dc5b20..2194ea0 100755 --- a/parse.js +++ b/parse.js @@ -37,6 +37,11 @@ const LRU_CACHE = 'def fib(n):\n' + ' return n if n < 2 else fib(n-2) + fib(n-1)\n'; +const CONSTRUCTOR_OVERLOADING = + 'class <name>:\n' + + ' def __init__(self, a=None):\n' + + ' self.a = a\n'; + const DATACLASS = 'from dataclasses import make_dataclass\n' + '<class> = make_dataclass(\'<class_name>\', <coll_of_attribute_names>)\n' + @@ -71,6 +76,20 @@ const PROGRESS_BAR = '... sleep(1)\n' + 'Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it]\n'; +const NUMPY_1 = + '<el> = <2d_array>[0, 0] # First element.\n' + + '<1d_view> = <2d_array>[0] # First row.\n' + + '<1d_view> = <2d_array>[:, 0] # First column. Also [..., 0].\n' + + '<3d_view> = <2d_array>[None, :, :] # Expanded by dimension of size 1.\n'; + +const NUMPY_2 = + '<1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>]\n' + + '<2d_array> = <2d_array>[<2d_row_indexes>, <2d_column_indexes>]\n'; + +const NUMPY_3 = + '<2d_bools> = <2d_array> > 0\n' + + '<1d_array> = <2d_array>[<2d_bools>]\n'; + const PYINSTALLER = '$ pip3 install pyinstaller\n' + '$ pyinstaller script.py # Compiles into \'./dist/script\' directory.\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(\'\')`).html(DATACLASS); $(`code:contains(shutil.copy)`).html(SHUTIL_COPY); $(`code:contains(os.rename)`).html(OS_RENAME); $(`code:contains(\'\', , )`).html(TYPE); $(`code:contains(ValueError: malformed node)`).html(EVAL); $(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR); + $(`code:contains( = <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); } diff --git a/pdf/README.md b/pdf/README.md index 9af2076..9e6a249 100644 --- a/pdf/README.md +++ b/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. )' by running 'pdf/remove_links.py' (Links can be found with this regex: `.*a href.*`). * Open `index.html` in text editor and first remove element `


      ` before the `

      Libraries

      `. * 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. )' by running 'pdf/remove_links.py' (Links can be found with this regex: `.*a href.*`). -* 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.