You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**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.**
2037
+
**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.**
2038
2038
2039
2039
```python
2040
2040
from array import array
2041
2041
```
2042
2042
2043
2043
```python
2044
2044
<array>= array('<typecode>', <coll_of_nums>) # Array from collection of numbers.
2045
-
<array>= array('<typecode>', <bytes>) #Array from bytes object.
2045
+
<array>= array('<typecode>', <bytes>) #Copies bytes to array's memory.
2046
2046
<array>= array('<typecode>', <array>) # Treats array as a sequence of numbers.
2047
-
<array>.fromfile(<file>, n_items) # Appends items from the binary file.
2047
+
<array>.fromfile(<file>, n_items) # Appends items from binary file.
2048
2048
```
2049
2049
2050
2050
```python
2051
2051
<bytes>=bytes(<array>) # Returns a copy of array's memory.
2052
-
<file>.write(<array>) # Writes array's memory to the file.
2052
+
<file>.write(<array>) # Writes array's memory to binary file.
2053
2053
```
2054
2054
2055
2055
@@ -2059,7 +2059,7 @@ Memory View
2059
2059
2060
2060
```python
2061
2061
<mview>=memoryview(<bytes/bytearray/array>) # Immutable if bytes, else mutable.
2062
-
<obj>=<mview>[index] # Returns int, float or bytes ('c' format).
2062
+
<obj>=<mview>[index] # Returns int/float (bytes if format is 'c').
2063
2063
<mview>=<mview>[<slice>] # Returns mview with rearranged elements.
2064
2064
<mview>=<mview>.cast('<typecode>') # Only works between B/b/c and other types.
2065
2065
<mview>.release() # Releases memory buffer of the base object.
@@ -2069,7 +2069,7 @@ Memory View
2069
2069
<bytes>=bytes(<mview>) # Returns a new bytes object.
2070
2070
<bytes>=<bytes>.join(<coll_of_mviews>) # Joins mviews using bytes as a separator.
2071
2071
<array>= array('<typecode>', <mview>) # Treats mview as a sequence of numbers.
2072
-
<file>.write(<mview>) # Writes `bytes(<mview>)` to the file.
2072
+
<file>.write(<mview>) # Writes `bytes(<mview>)` to binary file.
2073
2073
```
2074
2074
2075
2075
```python
@@ -2156,8 +2156,8 @@ with <lock>: # Enters the block by calling acq
2156
2156
<bool>=<Future>.cancel() # Cancels or returns False if running/finished.
2157
2157
<iter>= as_completed(<coll_of_Futures>) # `next(<iter>)` returns next completed Future.
2158
2158
```
2159
-
***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.**
2160
-
***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.**
2159
+
***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.**
2160
+
***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.**
2161
2161
***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__": ...'`.**
2162
2162
2163
2163
@@ -2680,7 +2680,7 @@ import numpy as np
2680
2680
2681
2681
```python
2682
2682
<array>= np.concatenate(<list_of_arrays>, axis=0) # Links arrays along first axis (rows).
2683
-
<array>= np.row_stack/column_stack(<list_of_arrays>) # Treats 1d arrays as rows or columns.
2683
+
<array>= np.vstack/column_stack(<list_of_arrays>)# Treats 1d arrays as rows or columns.
2684
2684
<array>= np.tile/repeat(<array>, <int/list> [, axis]) # Tiles array or repeats its elements.
2685
2685
```
2686
2686
***Shape is a tuple of dimension sizes. A 100x50 RGB image has shape (50, 100, 3).**
@@ -2772,7 +2772,7 @@ from PIL import Image
2772
2772
<Image>= Image.new('<mode>', (width, height)) # Creates new image. Also `color=<int/tuple>`.
2773
2773
<Image>= Image.open(<path>) # Identifies format based on file's contents.
2774
2774
<Image>=<Image>.convert('<mode>') # Converts image to the new mode.
2775
-
<Image>.save(<path>) # Selects format based on extension (png/jpg…).
2775
+
<Image>.save(<path>) # Selects format based on extension (PNG/JPG…).
2776
2776
<Image>.show() # Opens image in the default preview app.
2777
2777
```
2778
2778
@@ -2795,10 +2795,11 @@ from PIL import Image
2795
2795
```
2796
2796
2797
2797
### Modes
2798
-
***`'L'` - Lightness (i.e. greyscale). Each pixel is an int between 0 and 255.**
2799
-
***`'RGB'` - Red, green, blue (i.e. true color). Each pixel is a tuple of three ints.**
2800
-
***`'RGBA'` - RGB with alpha. Low alpha (forth int) means more transparency.**
2801
-
***`'HSV'` - Hue, saturation, value color space.**
2798
+
***`'L'` - Lightness (greyscale image). Each pixel is an int between 0 and 255.**
2799
+
***`'RGB'` - Red, green, blue (true color image). Each pixel is a tuple of three ints.**
2800
+
***`'RGBA'` - RGB with alpha. Low alpha (i.e. forth int) makes pixel more transparent.**
2801
+
***`'HSV'` - Hue, saturation, value. Three ints representing color in HSV color space.**
2802
+
2802
2803
2803
2804
### Examples
2804
2805
#### Creates a PNG image of a rainbow gradient:
@@ -2823,14 +2824,14 @@ img.show()
2823
2824
### Image Draw
2824
2825
```python
2825
2826
fromPILimport ImageDraw
2826
-
<ImageDraw>= ImageDraw.Draw(<Image>) # Object for adding 2D graphics to the image.
2827
-
<ImageDraw>.point((x, y)) # Draws a point. Truncates floats into ints.
2828
-
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize().
2829
-
<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction.
2830
-
<ImageDraw>.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
2831
-
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first.
2832
-
<ImageDraw>.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
0 commit comments