From 34a99438de7e2635f534d83a88540d33224a8e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 16 Oct 2023 18:33:08 +0200 Subject: [PATCH] Small changes --- README.md | 20 ++++++++++---------- index.html | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index cf2ac92..8f0557e 100644 --- a/README.md +++ b/README.md @@ -1870,8 +1870,8 @@ def read_csv_file(filename, dialect='excel', **params): ### Write Rows to CSV File ```python -def write_to_csv_file(filename, rows, dialect='excel', **params): - with open(filename, 'w', encoding='utf-8', newline='') as file: +def write_to_csv_file(filename, rows, mode='w', dialect='excel', **params): + with open(filename, mode, encoding='utf-8', newline='') as file: writer = csv.writer(file, dialect, **params) writer.writerows(rows) ``` @@ -2383,10 +2383,9 @@ Progress Bar ------------ ```python # $ pip3 install tqdm ->>> from tqdm import tqdm ->>> from time import sleep ->>> for el in tqdm([1, 2, 3], desc='Processing'): -... sleep(1) +>>> import tqdm, time +>>> for el in tqdm.tqdm([1, 2, 3], desc='Processing'): +... time.sleep(1) Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it] ``` @@ -2420,8 +2419,9 @@ print(table) Curses ------ -#### Runs a basic file explorer in the terminal: +#### Runs a basic file explorer in the console: ```python +# pip3 install windows-curses import curses, os from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER @@ -2619,7 +2619,7 @@ Line # Hits Time Per Hit % Time Line Contents $ pip3 install gprof2dot snakeviz; apt/brew install graphviz $ tail -n 4 test.py > test.py $ python3 -m cProfile -o test.prof test.py -$ gprof2dot -f pstats test.prof | dot -Tpng -o test.png; xdg-open/open test.png +$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png $ snakeviz test.prof ``` @@ -2778,7 +2778,7 @@ from PIL import Image, ImageFilter, ImageEnhance ``` ```python - = np.array() # Creates NumPy array from the image. + = np.array() # Creates a NumPy array from the image. = Image.fromarray(np.uint8()) # Use .clip(0, 255) to clip values. ``` @@ -3240,7 +3240,7 @@ b 3 4 ```python = [column_key/s] # Or: .column_key = [row_bools] # Keeps rows as specified by bools. - = [] # Assigns NaN to values that are False in bools. + = [] # Assigns NaN to items that are False in bools. ``` ```python diff --git a/index.html b/index.html index 869da71..73a8ad3 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1553,8 +1553,8 @@ CompletedProcess(args=['bc', return list(csv.reader(file, dialect, **params)) -

Write Rows to CSV File

def write_to_csv_file(filename, rows, dialect='excel', **params):
-    with open(filename, 'w', encoding='utf-8', newline='') as file:
+

Write Rows to CSV File

def write_to_csv_file(filename, rows, mode='w', dialect='excel', **params):
+    with open(filename, mode, encoding='utf-8', newline='') as file:
         writer = csv.writer(file, dialect, **params)
         writer.writerows(rows)
 
@@ -1979,7 +1979,7 @@ print(table)
-

#Curses

Runs a basic file explorer in the terminal:

import curses, os
+

#Curses

Runs a basic file explorer in the console:

import curses, os
 from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
 
 def main(screen):
@@ -2141,7 +2141,7 @@ Line #   Hits     Time  Per Hit   % Time  Line Contents
 

Call and Flame Graphs

$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
 $ tail -n 4 test.py > test.py
 $ python3 -m cProfile -o test.prof test.py
-$ gprof2dot -f pstats test.prof | dot -Tpng -o test.png; xdg-open/open test.png
+$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
 $ snakeviz test.prof
 
@@ -2262,7 +2262,7 @@ right = [[0.1, 0.6<Image> = <Image>.filter(<Filter>) # `<Filter> = ImageFilter.<name>([<args>])` <Image> = <Enhance>.enhance(<float>) # `<Enhance> = ImageEnhance.<name>(<Image>)`
-
<array> = np.array(<Image>)                       # Creates NumPy array from the image.
+
<array> = np.array(<Image>)                       # Creates a NumPy array from the image.
 <Image> = Image.fromarray(np.uint8(<array>))      # Use <array>.clip(0, 255) to clip values.
 

Modes

    @@ -2638,7 +2638,7 @@ b 3 4
<Sr/DF> = <DF>[column_key/s]                   # Or: <DF>.column_key
 <DF>    = <DF>[row_bools]                      # Keeps rows as specified by bools.
-<DF>    = <DF>[<DF_of_bools>]                  # Assigns NaN to values that are False in bools.
+<DF>    = <DF>[<DF_of_bools>]                  # Assigns NaN to items that are False in bools.
 
<DF>    = <DF> > <el/Sr/DF>                    # Returns DF of bools. Sr is treated as a row.
 <DF>    = <DF> + <el/Sr/DF>                    # Items with non-matching keys get value NaN.
@@ -2925,7 +2925,7 @@ $ deactivate                  # Deactivates the activ