From b85abfe0b2b13c31ec1ab46dd007f93c3d272a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 17 Apr 2025 19:51:03 +0200 Subject: [PATCH] Console app, NumPy --- README.md | 7 +++---- index.html | 18 ++++++++---------- parse.js | 11 +++++------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3a8f41a..a43225b 100644 --- a/README.md +++ b/README.md @@ -2448,8 +2448,8 @@ def main(screen): ch = screen.getch() selected -= (ch == KEY_UP) and (selected > 0) selected += (ch == KEY_DOWN) and (selected < len(paths)-1) - first = min(first, selected) - first = max(first, selected - (height-1)) + first -= (first > selected) + first += (first < selected-(height-1)) if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord('\n'), ord('\r')]: new_dir = '..' if ch == KEY_LEFT else paths[selected] if os.path.isdir(new_dir): @@ -2703,8 +2703,7 @@ import numpy as np <1/2d_arr> = <2d>[<2d/1d_bools>] # 1d_bools must have size of a column. ``` * **`':'` returns a slice of all dimension's indices. Omitted dimensions default to `':'`.** -* **Python converts `'obj[i, j]'` to `'obj[(i, j)]'`. This makes `'<2d>[row_i, col_i]'` and `'<2d>[row_indices]'` indistinguishable to NumPy if tuple of indices is passed!** -* **Indexing with a slice and 1d object works the same as when using two slices (lines 4, 6, 7).** +* **Python converts `'obj[i, j]'` to `'obj[(i, j)]'`. This makes `'<2d>[row_i, col_i]'` and `'<2d>[row_indices]'` indistinguishable to NumPy if tuple of two indices is passed!** * **`'ix_([1, 2], [3, 4])'` returns `'[[1], [2]]'` and `'[[3, 4]]'`. Due to broadcasting rules, this is the same as using `'[[1, 1], [2, 2]]'` and `'[[3, 4], [3, 4]]'`.** * **Any value that is broadcastable to the indexed shape can be assigned to the selection.** diff --git a/index.html b/index.html index 07c9c72..fed2451 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@
- +
@@ -844,11 +844,10 @@ csv.writer(<file>).writerow([<obj>]) raise Exception(<obj>) -

Expressions that call the repr() method:

print/str/repr([<obj>])
-print/str/repr({<obj>: <obj>})
-f'{<obj>!r}'
+

Expressions that call the repr() method:

print/str/repr([<obj>, ...])
+print/str/repr({<obj>: <obj>, ...})
 Z = make_dataclass('Z', ['a']); print/str/repr(Z(<obj>))
->>> <obj>
+f'{<obj>!r}'
 

Inheritance

class Person:
@@ -2017,8 +2016,8 @@ print(tabulate.tabulate(rows, headers='firstrow'and (selected > 0)
         selected += (ch == KEY_DOWN) and (selected < len(paths)-1)
-        first = min(first, selected)
-        first = max(first, selected - (height-1))
+        first -= (first > selected)
+        first += (first < selected-(height-1))
         if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord('\n'), ord('\r')]:
             new_dir = '..' if ch == KEY_LEFT else paths[selected]
             if os.path.isdir(new_dir):
@@ -2222,8 +2221,7 @@ $ snakeviz test.prof                                            ':' returns a slice of all dimension's indices. Omitted dimensions default to ':'.
-
  • Python converts 'obj[i, j]' to 'obj[(i, j)]'. This makes '<2d>[row_i, col_i]' and '<2d>[row_indices]' indistinguishable to NumPy if tuple of indices is passed!
  • -
  • Indexing with a slice and 1d object works the same as when using two slices (lines 4, 6, 7).
  • +
  • Python converts 'obj[i, j]' to 'obj[(i, j)]'. This makes '<2d>[row_i, col_i]' and '<2d>[row_indices]' indistinguishable to NumPy if tuple of two indices is passed!
  • 'ix_([1, 2], [3, 4])' returns '[[1], [2]]' and '[[3, 4]]'. Due to broadcasting rules, this is the same as using '[[1, 1], [2, 2]]' and '[[3, 4], [3, 4]]'.
  • Any value that is broadcastable to the indexed shape can be assigned to the selection.
  • @@ -2944,7 +2942,7 @@ $ deactivate # Deactivates the active diff --git a/parse.js b/parse.js index f238de4..f075167 100755 --- a/parse.js +++ b/parse.js @@ -80,11 +80,10 @@ const PARAMETRIZED_DECORATOR = ' return x + y\n'; const REPR_USE_CASES = - 'print/str/repr([<obj>])\n' + - 'print/str/repr({<obj>: <obj>})\n' + - 'f\'{<obj>!r}\'\n' + + 'print/str/repr([<obj>, ...])\n' + + 'print/str/repr({<obj>: <obj>, ...})\n' + 'Z = make_dataclass(\'Z\', [\'a\']); print/str/repr(Z(<obj>))\n' + - '>>> <obj>\n'; + 'f\'{<obj>!r}\'\n'; const CONSTRUCTOR_OVERLOADING = 'class <name>:\n' + @@ -188,8 +187,8 @@ const CURSES = ' ch = screen.getch()\n' + ' selected -= (ch == KEY_UP) and (selected > 0)\n' + ' selected += (ch == KEY_DOWN) and (selected < len(paths)-1)\n' + - ' first = min(first, selected)\n' + - ' first = max(first, selected - (height-1))\n' + + ' first -= (first > selected)\n' + + ' first += (first < selected-(height-1))\n' + ' if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord(\'\\n\'), ord(\'\\r\')]:\n' + ' new_dir = \'..\' if ch == KEY_LEFT else paths[selected]\n' + ' if os.path.isdir(new_dir):\n' +