diff --git a/README.md b/README.md index e589e46..5c8518f 100644 --- a/README.md +++ b/README.md @@ -1926,7 +1926,7 @@ with : # Exits the block with commit() [(1, 'Jean-Luc', 187)] ``` -### SqlAlchemy +### SQLAlchemy **Library for interacting with various DB systems via SQL, method chaining, or ORM.** ```python # $ pip3 install sqlalchemy @@ -2034,7 +2034,7 @@ b'\x00\x01\x00\x02\x00\x00\x00\x03' Array ----- -**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.** +**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be reversed with byteswap() method.** ```python from array import array @@ -2042,14 +2042,14 @@ from array import array ```python = array('', ) # Array from collection of numbers. - = array('', ) # Array from bytes object. + = array('', ) # Copies bytes to array's memory. = array('', ) # Treats array as a sequence of numbers. -.fromfile(, n_items) # Appends items from the binary file. +.fromfile(, n_items) # Appends items from binary file. ``` ```python = bytes() # Returns a copy of array's memory. -.write() # Writes array's memory to the file. +.write() # Writes array's memory to binary file. ``` @@ -2059,7 +2059,7 @@ Memory View ```python = memoryview() # Immutable if bytes, else mutable. - = [index] # Returns int, float or bytes ('c' format). + = [index] # Returns int/float (bytes if format is 'c'). = [] # Returns mview with rearranged elements. = .cast('') # Only works between B/b/c and other types. .release() # Releases memory buffer of the base object. @@ -2069,7 +2069,7 @@ Memory View = bytes() # Returns a new bytes object. = .join() # Joins mviews using bytes as a separator. = array('', ) # Treats mview as a sequence of numbers. -.write() # Writes `bytes()` to the file. +.write() # Writes `bytes()` to binary file. ``` ```python @@ -2156,8 +2156,8 @@ with : # Enters the block by calling acq = .cancel() # Cancels or returns False if running/finished. = as_completed() # `next()` returns next completed Future. ``` -* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if thread finished on time.** -* **Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. Its exception() method returns exception or None.** +* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if all threads have finished.** +* **Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.** * **ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be [pickable](#pickle), queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via `'if __name__ == "__main__": ...'`.** @@ -2680,7 +2680,7 @@ import numpy as np ```python = np.concatenate(, axis=0) # Links arrays along first axis (rows). - = np.row_stack/column_stack() # Treats 1d arrays as rows or columns. + = np.vstack/column_stack() # Treats 1d arrays as rows or columns. = np.tile/repeat(, [, axis]) # Tiles array or repeats its elements. ``` * **Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).** @@ -2772,7 +2772,7 @@ from PIL import Image = Image.new('', (width, height)) # Creates new image. Also `color=`. = Image.open() # Identifies format based on file's contents. = .convert('') # Converts image to the new mode. -.save() # Selects format based on extension (png/jpg…). +.save() # Selects format based on extension (PNG/JPG…). .show() # Opens image in the default preview app. ``` @@ -2795,10 +2795,11 @@ from PIL import Image ``` ### Modes -* **`'L'` - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.** -* **`'RGB'` - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.** -* **`'RGBA'` - RGB with alpha. Low alpha (forth int) means more transparency.** -* **`'HSV'` - Hue, saturation, value color space.** +* **`'L'` - Lightness (greyscale image). Each pixel is an int between 0 and 255.** +* **`'RGB'` - Red, green, blue (true color image). Each pixel is a tuple of three ints.** +* **`'RGBA'` - RGB with alpha. Low alpha (i.e. forth int) makes pixel more transparent.** +* **`'HSV'` - Hue, saturation, value. Three ints representing color in HSV color space.** + ### Examples #### Creates a PNG image of a rainbow gradient: @@ -2823,14 +2824,14 @@ img.show() ### Image Draw ```python from PIL import ImageDraw - = ImageDraw.Draw() # Object for adding 2D graphics to the image. -.point((x, y)) # Draws a point. Truncates floats into ints. -.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize(). -.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. -.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste(). -.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first. -.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste(). -.text((x, y), , font=) # ` = ImageFont.truetype(, size)` + = ImageDraw.Draw() # Object for adding 2D graphics to the image. +.point((x, y)) # Draws a point. Truncates floats into ints. +.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize(). +.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. +.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste(). +.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first. +.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste(). +.text((x, y), , font=) # ` = ImageFont.truetype(, size)` ``` * **Use `'fill='` to set the primary color.** * **Use `'width='` to set the width of lines or contours.** diff --git a/index.html b/index.html index 3c707b5..e3d1869 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1598,7 +1598,7 @@ CompletedProcess(args=['bc', SqlAlchemy

Library for interacting with various DB systems via SQL, method chaining, or ORM.

# $ pip3 install sqlalchemy
+

SQLAlchemy

Library for interacting with various DB systems via SQL, method chaining, or ORM.

# $ pip3 install sqlalchemy
 from sqlalchemy import create_engine, text
 <engine> = create_engine('<url>')               # Url: 'dialect://user:password@host/dbname'.
 <conn>   = <engine>.connect()                   # Creates a connection. Also <conn>.close().
@@ -1685,20 +1685,20 @@ CompletedProcess(args=['bc', #Array

List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.

from array import array
+

#Array

List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be reversed with byteswap() method.

from array import array
 
<array> = array('<typecode>', <coll_of_nums>)  # Array from collection of numbers.
-<array> = array('<typecode>', <bytes>)         # Array from bytes object.
+<array> = array('<typecode>', <bytes>)         # Copies bytes to array's memory.
 <array> = array('<typecode>', <array>)         # Treats array as a sequence of numbers.
-<array>.fromfile(<file>, n_items)              # Appends items from the binary file.
+<array>.fromfile(<file>, n_items)              # Appends items from binary file.
 
<bytes> = bytes(<array>)                       # Returns a copy of array's memory.
-<file>.write(<array>)                          # Writes array's memory to the file.
+<file>.write(<array>)                          # Writes array's memory to binary file.
 

#Memory View

A sequence object that points to the memory of another bytes-like object. Each element can reference a single or multiple consecutive bytes, depending on format. Order and number of elements can be changed with slicing.

<mview> = memoryview(<bytes/bytearray/array>)  # Immutable if bytes, else mutable.
-<obj>   = <mview>[index]                       # Returns int, float or bytes ('c' format).
+<obj>   = <mview>[index]                       # Returns int/float (bytes if format is 'c').
 <mview> = <mview>[<slice>]                     # Returns mview with rearranged elements.
 <mview> = <mview>.cast('<typecode>')           # Only works between B/b/c and other types.
 <mview>.release()                              # Releases memory buffer of the base object.
@@ -1708,7 +1708,7 @@ CompletedProcess(args=['bc', <bytes> = bytes(<mview>)                       # Returns a new bytes object.
 <bytes> = <bytes>.join(<coll_of_mviews>)       # Joins mviews using bytes as a separator.
 <array> = array('<typecode>', <mview>)         # Treats mview as a sequence of numbers.
-<file>.write(<mview>)                          # Writes `bytes(<mview>)` to the file.
+<file>.write(<mview>)                          # Writes `bytes(<mview>)` to binary file.
 
<list>  = list(<mview>)                        # Returns a list of ints, floats or bytes.
 <str>   = str(<mview>, 'utf-8')                # Treats mview as a bytes object.
@@ -1771,8 +1771,8 @@ CompletedProcess(args=['bc', # `next(<iter>)` returns next completed Future.
 
    -
  • Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As_completed() fails if next() is called too late, even if thread finished on time.
  • -
  • Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. Its exception() method returns exception or None.
  • +
  • Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As_completed() fails if next() is called too late, even if all threads have finished.
  • +
  • Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.
  • ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via 'if __name__ == "__main__": ...'.

#Operator

Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.

import operator as op
@@ -2191,7 +2191,7 @@ $ snakeviz test.prof                                            # Func can return a scalar or array.
 
<array> = np.concatenate(<list_of_arrays>, axis=0)      # Links arrays along first axis (rows).
-<array> = np.row_stack/column_stack(<list_of_arrays>)   # Treats 1d arrays as rows or columns.
+<array> = np.vstack/column_stack(<list_of_arrays>)      # Treats 1d arrays as rows or columns.
 <array> = np.tile/repeat(<array>, <int/list> [, axis])  # Tiles array or repeats its elements.
 
    @@ -2265,7 +2265,7 @@ right = [[0.1, 0.1<Image> = Image.new('<mode>', (width, height)) # Creates new image. Also `color=<int/tuple>`. <Image> = Image.open(<path>) # Identifies format based on file's contents. <Image> = <Image>.convert('<mode>') # Converts image to the new mode. -<Image>.save(<path>) # Selects format based on extension (png/jpg…). +<Image>.save(<path>) # Selects format based on extension (PNG/JPG…). <Image>.show() # Opens image in the default preview app.
<int/tuple> = <Image>.getpixel((x, y))          # Returns pixel's value (its color).
@@ -2281,10 +2281,10 @@ right = [[0.1,  0.1# Use `<array>.clip(0, 255)` to clip values.
 

Modes

    -
  • 'L' - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.
  • -
  • 'RGB' - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.
  • -
  • 'RGBA' - RGB with alpha. Low alpha (forth int) means more transparency.
  • -
  • 'HSV' - Hue, saturation, value color space.
  • +
  • 'L' - Lightness (greyscale image). Each pixel is an int between 0 and 255.
  • +
  • 'RGB' - Red, green, blue (true color image). Each pixel is a tuple of three ints.
  • +
  • 'RGBA' - RGB with alpha. Low alpha (i.e. forth int) makes pixel more transparent.
  • +
  • 'HSV' - Hue, saturation, value. Three ints representing color in HSV color space.

Examples

Creates a PNG image of a rainbow gradient:

WIDTH, HEIGHT = 100, 100
 n_pixels = WIDTH * HEIGHT
 hues = (255 * i/n_pixels for i in range(n_pixels))
@@ -2304,14 +2304,14 @@ img.show()
 

Image Draw

from PIL import ImageDraw
-<ImageDraw> = ImageDraw.Draw(<Image>)           # Object for adding 2D graphics to the image.
-<ImageDraw>.point((x, y))                       # Draws a point. Truncates floats into ints.
-<ImageDraw>.line((x1, y1, x2, y2 [, ...]))      # To get anti-aliasing use Image's resize().
-<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2)   # Always draws in clockwise direction.
-<ImageDraw>.rectangle((x1, y1, x2, y2))         # To rotate use Image's rotate() and paste().
-<ImageDraw>.polygon((x1, y1, x2, y2, ...))      # Last point gets connected to the first.
-<ImageDraw>.ellipse((x1, y1, x2, y2))           # To rotate use Image's rotate() and paste().
-<ImageDraw>.text((x, y), <str>, font=<Font>)    # `<Font> = ImageFont.truetype(<path>, size)`
+<Draw> = ImageDraw.Draw(<Image>)                # Object for adding 2D graphics to the image.
+<Draw>.point((x, y))                            # Draws a point. Truncates floats into ints.
+<Draw>.line((x1, y1, x2, y2 [, ...]))           # To get anti-aliasing use Image's resize().
+<Draw>.arc((x1, y1, x2, y2), deg1, deg2)        # Always draws in clockwise direction.
+<Draw>.rectangle((x1, y1, x2, y2))              # To rotate use Image's rotate() and paste().
+<Draw>.polygon((x1, y1, x2, y2, ...))           # Last point gets connected to the first.
+<Draw>.ellipse((x1, y1, x2, y2))                # To rotate use Image's rotate() and paste().
+<Draw>.text((x, y), <str>, font=<Font>)         # `<Font> = ImageFont.truetype(<path>, size)`
 
    @@ -2931,7 +2931,7 @@ $ deactivate # Deactivates the active