diff --git a/README.md b/README.md index 1ea48ce..6909f1f 100644 --- a/README.md +++ b/README.md @@ -500,7 +500,7 @@ Numbers ### Math ```python from math import e, pi, inf, nan, isinf, isnan -from math import cos, acos, sin, asin, tan, atan, degrees, radians +from math import cos, sin, tan, acos, asin, atan, degrees, radians from math import log, log10, log2 ``` @@ -599,7 +599,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary ``` * **Use `'.weekday()'` to get the day of the week (Mon == 0).** * **`'fold=1'` means the second pass in case of time jumping back for one hour.** -* **`' = resolve_imaginary()'` fixes DTs that fall into the missing hour.** +* **`' = resolve_imaginary()'` fixes DTs that fall into missing hour.** ### Now ```python @@ -1782,7 +1782,7 @@ import csv = next() # Returns next row as a list of strings. = list() # Returns list of remaining rows. ``` -* **File must be opened with `'newline=""'` argument, or newlines embedded inside quoted fields will not be interpreted correctly!** +* **File must be opened with a `'newline=""'` argument, or newlines embedded inside quoted fields will not be interpreted correctly!** ### Write ```python @@ -1790,7 +1790,7 @@ import csv .writerow() # Encodes objects using `str()`. .writerows() # Appends multiple rows. ``` -* **File must be opened with `'newline=""'` argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!** +* **File must be opened with a `'newline=""'` argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!** ### Parameters * **`'dialect'` - Master parameter that sets the default values.** @@ -1805,15 +1805,15 @@ import csv ### Dialects ```text +------------------+--------------+--------------+--------------+ -| | excel | excel-tab | unix | +| | excel | excel-tab | unix | +------------------+--------------+--------------+--------------+ -| delimiter | ',' | '\t' | ',' | -| quotechar | '"' | '"' | '"' | -| doublequote | True | True | True | -| skipinitialspace | False | False | False | -| lineterminator | '\r\n' | '\r\n' | '\n' | -| quoting | 0 | 0 | 1 | -| escapechar | None | None | None | +| delimiter | ',' | '\t' | ',' | +| quotechar | '"' | '"' | '"' | +| doublequote | True | True | True | +| skipinitialspace | False | False | False | +| lineterminator | '\r\n' | '\r\n' | '\n' | +| quoting | 0 | 0 | 1 | +| escapechar | None | None | None | +------------------+--------------+--------------+--------------+ ``` @@ -1879,10 +1879,10 @@ with : ```python >>> conn = sqlite3.connect('test.db') ->>> conn.execute('create table person (person_id integer primary key, name, height)') ->>> conn.execute('insert into person values (null, ?, ?)', ('Jean-Luc', 187)).lastrowid +>>> conn.execute('CREATE TABLE person (person_id INTEGER PRIMARY KEY, name, height)') +>>> conn.execute('INSERT INTO person VALUES (NULL, ?, ?)', ('Jean-Luc', 187)).lastrowid 1 ->>> conn.execute('select * from person').fetchall() +>>> conn.execute('SELECT * FROM person').fetchall() [(1, 'Jean-Luc', 187)] ``` @@ -2087,7 +2087,7 @@ from concurrent.futures import ThreadPoolExecutor ```python = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as : …` -.shutdown(wait=True) # Gets called at the end of 'with' block. +.shutdown(wait=True) # Blocks until all threads finish executing. ``` ```python @@ -2542,7 +2542,7 @@ duration = perf_counter() - start_time ### Timing a Snippet ```python >>> from timeit import timeit ->>> timeit('"".join(str(i) for i in range(100))', +>>> timeit("''.join(str(i) for i in range(100))", ... number=10000, globals=globals(), setup='pass') 0.34986 ``` @@ -2623,24 +2623,22 @@ indexes = .argmin(axis) ### Indexing ```bash - = <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. + = <2d_array>[row_index, column_index] +<1d_view> = <2d_array>[row_index] +<1d_view> = <2d_array>[:, column_index] ``` ```bash -<1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>] -<2d_array> = <2d_array>[<2d_row_indexes>, <2d_column_indexes>] +<1d_array> = <2d_array>[row_indexes, column_indexes] +<2d_array> = <2d_array>[row_indexes] +<2d_array> = <2d_array>[:, column_indexes] ``` ```bash -<2d_bools> = <2d_array> > 0 +<2d_bools> = <2d_array> ><== <1d_array> = <2d_array>[<2d_bools>] ``` -* **If row and column indexes differ in shape, they are combined with broadcasting.** - ### Broadcasting **Broadcasting is a set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.** @@ -2899,8 +2897,8 @@ Synthesizer #### Plays Popcorn by Gershon Kingsley: ```python # $ pip3 install simpleaudio -import simpleaudio, math, struct -from itertools import chain, repeat +import math, struct, simpleaudio +from itertools import repeat, chain F = 44100 P1 = '71♩,69♪,,71♩,66♪,,62♩,66♪,,59♩,,,' P2 = '71♩,73♪,,74♩,73♪,,74♪,,71♪,,73♩,71♪,,73♪,,69♪,,71♩,69♪,,71♪,,67♪,,71♩,,,' diff --git a/index.html b/index.html index 0acc544..68b79e8 100644 --- a/index.html +++ b/index.html @@ -606,7 +606,7 @@ to_exclusive = <range>.stop

Math

from math import e, pi, inf, nan, isinf, isnan
-from math import cos, acos, sin, asin, tan, atan, degrees, radians
+from math import cos, sin, tan, acos, asin, atan, degrees, radians
 from math import log, log10, log2
 
@@ -681,7 +681,7 @@ to_exclusive = <range>.stop
  • Use '<D/DT>.weekday()' to get the day of the week (Mon == 0).
  • 'fold=1' means the second pass in case of time jumping back for one hour.
  • -
  • '<DTa> = resolve_imaginary(<DTa>)' fixes DTs that fall into the missing hour.
  • +
  • '<DTa> = resolve_imaginary(<DTa>)' fixes DTs that fall into missing hour.

Now

<D/DTn>  = D/DT.today()                     # Current local date or naive datetime.
 <DTn>    = DT.utcnow()                      # Naive datetime from current UTC time.
@@ -1626,7 +1626,7 @@ CompletedProcess(args=['bc', 'newline=""' argument, or newlines embedded inside quoted fields will not be interpreted correctly!
+
  • File must be opened with a 'newline=""' argument, or newlines embedded inside quoted fields will not be interpreted correctly!
  • Write

    <writer> = csv.writer(<file>)       # Also: `dialect='excel', delimiter=','`.
     <writer>.writerow(<collection>)     # Encodes objects using `str(<el>)`.
    @@ -1634,7 +1634,7 @@ CompletedProcess(args=['bc', 'newline=""' argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!
    +
  • File must be opened with a 'newline=""' argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!
  • Parameters

    • 'dialect' - Master parameter that sets the default values.
    • @@ -1646,15 +1646,15 @@ CompletedProcess(args=['bc', 'quoting' - Controls the amount of quoting: 0 - as necessary, 1 - all.
    • 'escapechar' - Character for escaping 'quotechar' if 'doublequote' is False.

    Dialects

    ┏━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓
    -┃                  │     excel    │   excel-tab  │     unix     ┃
    +┃                  │    excel     │   excel-tab  │     unix     ┃
     ┠──────────────────┼──────────────┼──────────────┼──────────────┨
    -┃ delimiter        │       ','    │      '\t'    │       ','    ┃
    -┃ quotechar        │       '"'    │       '"'    │       '"'    ┃
    -┃ doublequote      │      True    │      True    │      True    ┃
    -┃ skipinitialspace │     False    │     False    │     False    ┃
    -┃ lineterminator   │    '\r\n'    │    '\r\n'    │      '\n'    ┃
    -┃ quoting          │         0    │         0    │         1    ┃
    -┃ escapechar       │      None    │      None    │      None    ┃
    +┃ delimiter        │    ','       │    '\t'      │    ','       ┃
    +┃ quotechar        │    '"'       │    '"'       │    '"'       ┃
    +┃ doublequote      │    True      │    True      │     True     ┃
    +┃ skipinitialspace │    False     │    False     │     False    ┃
    +┃ lineterminator   │    '\r\n'    │    '\r\n'    │    '\n'      ┃
    +┃ quoting          │    0         │    0         │     1        ┃
    +┃ escapechar       │    None      │    None      │     None     ┃
     ┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛
     
    @@ -1703,10 +1703,10 @@ CompletedProcess(args=['bc', Example

    In this example values are not actually saved because 'conn.commit()' is omitted!

    >>> conn = sqlite3.connect('test.db')
    ->>> conn.execute('create table person (person_id integer primary key, name, height)')
    ->>> conn.execute('insert into person values (null, ?, ?)', ('Jean-Luc', 187)).lastrowid
    +>>> conn.execute('CREATE TABLE person (person_id INTEGER PRIMARY KEY, name, height)')
    +>>> conn.execute('INSERT INTO person VALUES (NULL, ?, ?)', ('Jean-Luc', 187)).lastrowid
     1
    ->>> conn.execute('select * from person').fetchall()
    +>>> conn.execute('SELECT * FROM person').fetchall()
     [(1, 'Jean-Luc', 187)]
     
    @@ -1865,7 +1865,7 @@ CompletedProcess(args=['bc', <Exec> = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as <name>: …` -<Exec>.shutdown(wait=True) # Gets called at the end of 'with' block. +<Exec>.shutdown(wait=True) # Blocks until all threads finish executing.
    <iter> = <Exec>.map(<func>, <args_1>, ...)     # A multithreaded and non-lazy map().
     <Futr> = <Exec>.submit(<func>, <arg_1>, ...)   # Starts a thread and returns its Future object.
    @@ -2214,7 +2214,7 @@ duration = perf_counter() - start_time
     

    Timing a Snippet

    >>> from timeit import timeit
    ->>> timeit('"".join(str(i) for i in range(100))',
    +>>> timeit("''.join(str(i) for i in range(100))",
     ...        number=10000, globals=globals(), setup='pass')
     0.34986
     
    @@ -2275,21 +2275,18 @@ indexes = <array>.argmin(axis)
  • Shape is a tuple of dimension sizes.
  • Axis is an index of the dimension that gets collapsed. 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>[row_index, column_index]
    +<1d_view>  = <2d_array>[row_index]
    +<1d_view>  = <2d_array>[:, column_index]
     
    -
    <1d_array> = <2d_array>[<1d_row_indexes>, <1d_column_indexes>]
    -<2d_array> = <2d_array>[<2d_row_indexes>, <2d_column_indexes>]
    +
    <1d_array> = <2d_array>[row_indexes, column_indexes]
    +<2d_array> = <2d_array>[row_indexes]
    +<2d_array> = <2d_array>[:, column_indexes]
     
    -
    <2d_bools> = <2d_array> > 0
    +
    <2d_bools> = <2d_array> ><== <el>
     <1d_array> = <2d_array>[<2d_bools>]
     
    -
      -
    • If row and column indexes differ in shape, they are combined with broadcasting.
    • -

    Broadcasting

    Broadcasting is a set of rules by which NumPy functions operate on arrays of different sizes and/or dimensions.

    left  = [[0.1], [0.6], [0.8]]        # Shape: (3, 1)
     right = [ 0.1 ,  0.6 ,  0.8 ]        # Shape: (3)
     
    @@ -2492,8 +2489,8 @@ engine.runAndWait()

    #Synthesizer

    Plays Popcorn by Gershon Kingsley:

    # $ pip3 install simpleaudio
    -import simpleaudio, math, struct
    -from itertools import chain, repeat
    +import math, struct, simpleaudio
    +from itertools import repeat, chain
     F  = 44100
     P1 = '71♩,69♪,,71♩,66♪,,62♩,66♪,,59♩,,,'
     P2 = '71♩,73♪,,74♩,73♪,,74♪,,71♪,,73♩,71♪,,73♪,,69♪,,71♩,69♪,,71♪,,67♪,,71♩,,,'
    diff --git a/parse.js b/parse.js
    index 606524f..9d6d8d7 100755
    --- a/parse.js
    +++ b/parse.js
    @@ -74,20 +74,6 @@ 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' +
    @@ -244,20 +230,20 @@ const DIAGRAM_8_B =
     
     const DIAGRAM_9_A =
       '+------------------+--------------+--------------+--------------+\n' +
    -  '|                  |     excel    |   excel-tab  |     unix     |\n' +
    +  '|                  |    excel     |   excel-tab  |     unix     |\n' +
       '+------------------+--------------+--------------+--------------+\n';
     
     const DIAGRAM_9_B =
       "┏━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n" +
    -  "┃                  │     excel    │   excel-tab  │     unix     ┃\n" +
    +  "┃                  │    excel     │   excel-tab  │     unix     ┃\n" +
       "┠──────────────────┼──────────────┼──────────────┼──────────────┨\n" +
    -  "┃ delimiter        │       ','    │      '\\t'    │       ','    ┃\n" +
    -  "┃ quotechar        │       '\"'    │       '\"'    │       '\"'    ┃\n" +
    -  "┃ doublequote      │      True    │      True    │      True    ┃\n" +
    -  "┃ skipinitialspace │     False    │     False    │     False    ┃\n" +
    -  "┃ lineterminator   │    '\\r\\n'    │    '\\r\\n'    │      '\\n'    ┃\n" +
    -  "┃ quoting          │         0    │         0    │         1    ┃\n" +
    -  "┃ escapechar       │      None    │      None    │      None    ┃\n" +
    +  "┃ delimiter        │    ','       │    '\\t'      │    ','       ┃\n" +
    +  "┃ quotechar        │    '\"'       │    '\"'       │    '\"'       ┃\n" +
    +  "┃ doublequote      │    True      │    True      │     True     ┃\n" +
    +  "┃ skipinitialspace │    False     │    False     │     False    ┃\n" +
    +  "┃ lineterminator   │    '\\r\\n'    │    '\\r\\n'    │    '\\n'      ┃\n" +
    +  "┃ quoting          │    0         │    0         │     1        ┃\n" +
    +  "┃ escapechar       │    None      │    None      │     None     ┃\n" +
       "┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n";
     
     const DIAGRAM_10_A =
    @@ -530,9 +516,6 @@ function fixHighlights() {
       $(`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).removeClass().addClass("python language-python hljs");
    -  $(`code:contains(<1d_array> = <2d_array>[<1d_row_indexes>)`).html(NUMPY_2).removeClass().addClass("python language-python hljs");
    -  $(`code:contains(<2d_bools> = <2d_array> > 0)`).html(NUMPY_3).removeClass().addClass("python language-python hljs");
       $(`code:contains(pip3 install pyinstaller)`).html(PYINSTALLER);
       $(`ul:contains(Only available in)`).html(INDEX);
     }