diff --git a/README.md b/README.md index 3a4bad1..393da6e 100644 --- a/README.md +++ b/README.md @@ -769,12 +769,15 @@ Inline ``` ### Map, Filter, Reduce +```python +from functools import reduce +``` + ```python = map(lambda x: x + 1, range(10)) # Or: iter([1, 2, ..., 10]) = filter(lambda x: x > 5, range(10)) # Or: iter([6, 7, 8, 9]) = reduce(lambda out, x: out + x, range(10)) # Or: 45 ``` -* **Reduce must be imported from the functools module.** ### Any, All ```python @@ -2679,14 +2682,14 @@ import numpy as np = <2d_array>[row_index, column_index] # <3d_a>[table_i, row_i, column_i] <1d_view> = <2d_array>[row_index] # <3d_a>[table_i, row_i] <1d_view> = <2d_array>[:, column_index] # <3d_a>[table_i, :, column_i] -<2d_view> = <2d_array>[row_range, column_range] # <3d_a>[table_i, row_r, column_r] +<2d_view> = <2d_array>[rows_slice, columns_slice] # <3d_a>[table_i, rows_s, columns_s] ``` ```perl -<2d_array> = <2d_array>[row_indexes] # <3d_a>[table_i/s, row_is] -<2d_array> = <2d_array>[:, column_indexes] # <3d_a>[table_i/s, :, column_is] -<1d_array> = <2d_array>[row_indexes, column_indexes] # <3d_a>[table_i/s, row_is, column_is] -<1d_array> = <2d_array>[row_indexes, column_index] # <3d_a>[table_i/s, row_is, column_i] +<2d_array> = <2d_array>[row_indexes] # <3d_a>[table_i/is, row_is] +<2d_array> = <2d_array>[:, column_indexes] # <3d_a>[table_i/is, :, column_is] +<1d_array> = <2d_array>[row_indexes, column_indexes] # <3d_a>[table_i/is, row_is, column_is] +<1d_array> = <2d_array>[row_indexes, column_index] # <3d_a>[table_i/is, row_is, column_i] ``` ```perl @@ -2762,7 +2765,7 @@ from PIL import Image, ImageDraw = Image.open() # Identifies format based on file contents. = .convert('') # Converts image to the new mode. .save() # Selects format based on the path extension. -.show() # Opens image in default preview app. +.show() # Opens image in the default preview app. ``` ```python @@ -3015,7 +3018,8 @@ while not pg.event.get(pg.QUIT): ```python = pg.display.set_mode((width, height)) # Opens new window and returns its surface. = pg.Surface((width, height)) # New RGB surface. RGBA if `flags=pg.SRCALPHA`. - = pg.image.load('') # Loads the image. Format depends on source. + = pg.image.load() # Loads the image. Format depends on source. + = pg.surfarray.make_surface() # Also ` = surfarray.pixels3d()`. = .subsurface() # Returns a subsurface. ``` @@ -3041,14 +3045,13 @@ rect(, color, , width=0) # Also polygon(, color, po ### Font ```python - = pg.font.SysFont('', size) # Loads the system font or default if missing. - = pg.font.Font('', size) # Loads the TTF file. Pass None for default. + = pg.font.Font(, size) # Loads the TTF file. Pass None for default. = .render(text, antialias, color) # Background color can be specified at the end. ``` ### Sound ```python - = pg.mixer.Sound('') # Loads the WAV file. + = pg.mixer.Sound() # Loads the WAV file or array of signed shorts. .play() # Starts playing the sound. ``` @@ -3161,7 +3164,7 @@ Name: a, dtype: int64 ```python = [key/index] # Or: .key - = [keys/indexes] # Or: [] + = [keys/indexes] # Or: [] = [bools] # Or: .i/loc[bools] ``` diff --git a/index.html b/index.html index 0f58077..bc53873 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -660,14 +660,13 @@ func(*args, **kwargs)
>>> [l+r for l in 'abc' for r in 'abc']
 ['aa', 'ab', 'ac', ..., 'cc']
 
-

Map, Filter, Reduce

<iter> = map(lambda x: x + 1, range(10))            # Or: iter([1, 2, ..., 10])
-<iter> = filter(lambda x: x > 5, range(10))         # Or: iter([6, 7, 8, 9])
-<obj>  = reduce(lambda out, x: out + x, range(10))  # Or: 45
+

Map, Filter, Reduce

from functools import reduce
 
-
    -
  • Reduce must be imported from the functools module.
  • -
+
<iter> = map(lambda x: x + 1, range(10))            # Or: iter([1, 2, ..., 10])
+<iter> = filter(lambda x: x > 5, range(10))         # Or: iter([6, 7, 8, 9])
+<obj>  = reduce(lambda out, x: out + x, range(10))  # Or: 45
+

Any, All

<bool> = any(<collection>)                          # Is `bool(<el>)` True for any element.
 <bool> = all(<collection>)                          # Is True for all elements or empty.
 
@@ -2193,13 +2192,13 @@ drawer = cg.output.GraphvizOutput(output_file=filename)

Indexing

<el>       = <2d_array>[row_index, column_index]        # <3d_a>[table_i, row_i, column_i]
 <1d_view>  = <2d_array>[row_index]                      # <3d_a>[table_i, row_i]
 <1d_view>  = <2d_array>[:, column_index]                # <3d_a>[table_i, :, column_i]
-<2d_view>  = <2d_array>[row_range, column_range]        # <3d_a>[table_i, row_r, column_r]
+<2d_view>  = <2d_array>[rows_slice, columns_slice]      # <3d_a>[table_i, rows_s, columns_s]
 
-
<2d_array> = <2d_array>[row_indexes]                    # <3d_a>[table_i/s, row_is]
-<2d_array> = <2d_array>[:, column_indexes]              # <3d_a>[table_i/s, :, column_is]
-<1d_array> = <2d_array>[row_indexes, column_indexes]    # <3d_a>[table_i/s, row_is, column_is]
-<1d_array> = <2d_array>[row_indexes, column_index]      # <3d_a>[table_i/s, row_is, column_i]
+
<2d_array> = <2d_array>[row_indexes]                    # <3d_a>[table_i/is, row_is]
+<2d_array> = <2d_array>[:, column_indexes]              # <3d_a>[table_i/is, :, column_is]
+<1d_array> = <2d_array>[row_indexes, column_indexes]    # <3d_a>[table_i/is, row_is, column_is]
+<1d_array> = <2d_array>[row_indexes, column_index]      # <3d_a>[table_i/is, row_is, column_i]
 
<2d_bools> = <2d_array> ><== <el/1d/2d_array>           # 1d_array must have size of a row.
 <1d/2d_a>  = <2d_array>[<2d/1d_bools>]                  # 1d_bools must have size of a column.
@@ -2259,7 +2258,7 @@ right = [[0.1,  0.6# Identifies format based on file contents.
 <Image> = <Image>.convert('<mode>')             # Converts image to the new mode.
 <Image>.save(<path>)                            # Selects format based on the path extension.
-<Image>.show()                                  # Opens image in default preview app.
+<Image>.show()                                  # Opens image in the default preview app.
 
<int/tuple> = <Image>.getpixel((x, y))          # Returns a pixel.
 <Image>.putpixel((x, y), <int/tuple>)           # Writes a pixel to the image.
@@ -2463,7 +2462,8 @@ rect = pg.Rect(240, 2
 

Surface

Object for representing images.

<Surf> = pg.display.set_mode((width, height))   # Opens new window and returns its surface.
 <Surf> = pg.Surface((width, height))            # New RGB surface. RGBA if `flags=pg.SRCALPHA`.
-<Surf> = pg.image.load('<path>')                # Loads the image. Format depends on source.
+<Surf> = pg.image.load(<path/file>)             # Loads the image. Format depends on source.
+<Surf> = pg.surfarray.make_surface(<np_array>)  # Also `<array> = surfarray.pixels3d(<Surf>)`.
 <Surf> = <Surf>.subsurface(<Rect>)              # Returns a subsurface.
 
@@ -2482,12 +2482,11 @@ line(<Surf>, color, (x1, y1), (x2, y2), width) # Also ellipse(<Surf>, color, <Rect>, width=0). rect(<Surf>, color, <Rect>, width=0) # Also polygon(<Surf>, color, points, width=0).
-

Font

<Font> = pg.font.SysFont('<name>', size)        # Loads the system font or default if missing.
-<Font> = pg.font.Font('<path>', size)           # Loads the TTF file. Pass None for default.
+

Font

<Font> = pg.font.Font(<path/file>, size)        # Loads the TTF file. Pass None for default.
 <Surf> = <Font>.render(text, antialias, color)  # Background color can be specified at the end.
 
-

Sound

<Sound> = pg.mixer.Sound('<path>')              # Loads the WAV file.
+

Sound

<Sound> = pg.mixer.Sound(<path/file/bytes>)     # Loads the WAV file or array of signed shorts.
 <Sound>.play()                                  # Starts playing the sound.
 
@@ -2586,7 +2585,7 @@ Name: a, dtype: int64 <Sr> = <Sr>.loc[from_key : to_key_inclusive] # Or: <Sr>.iloc[from_i : to_i_exclusive]
<el> = <Sr>[key/index]                         # Or: <Sr>.key
-<Sr> = <Sr>[keys/indexes]                      # Or: <Sr>[<key_range/range>]
+<Sr> = <Sr>[keys/indexes]                      # Or: <Sr>[<keys_slice/slice>]
 <Sr> = <Sr>[bools]                             # Or: <Sr>.i/loc[bools]
 
<Sr> = <Sr> ><== <el/Sr>                       # Returns a Series of bools.
@@ -2935,7 +2934,7 @@ $ pyinstaller script.py --add-data '<path>:.'