From 798f61b6d9e2109fcbfaa3b61244e73ab27b060d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sat, 24 Aug 2024 17:15:56 +0200 Subject: [PATCH] Open, Array, Memory view, Plot --- README.md | 13 +++++++------ index.html | 17 +++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d248e84..826d038 100644 --- a/README.md +++ b/README.md @@ -1572,7 +1572,7 @@ Open ### Modes * **`'r'` - Read (default).** -* **`'w'` - Write (truncate).** +* **`'w'` - Write (truncate, i.e. delete existing contents).** * **`'x'` - Write or fail if the file already exists.** * **`'a'` - Append.** * **`'w+'` - Read and write (truncate).** @@ -2049,7 +2049,7 @@ from array import array ```python = bytes() # Returns a copy of array's memory. -.write() # Writes array to the binary file. +.write() # Writes array's memory to the file. ``` @@ -2059,9 +2059,9 @@ Memory View ```python = memoryview() # Immutable if bytes, else mutable. - = [index] # Returns an int or a float. + = [index] # Returns int, float or bytes ('c' format). = [] # Returns mview with rearranged elements. - = .cast('') # Only works between b/B/c and other types. + = .cast('') # Only works between B/b/c and other types. .release() # Releases memory buffer of the base object. ``` @@ -2069,11 +2069,11 @@ 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 mview to the binary file. +.write() # Writes `bytes()` to the file. ``` ```python - = list() # Returns a list of ints or floats. + = list() # Returns a list of ints, floats or bytes. = str(, 'utf-8') # Treats mview as a bytes object. = .hex() # Returns hex pairs. Accepts `sep=`. ``` @@ -2413,6 +2413,7 @@ import matplotlib.pyplot as plt plt.plot/bar/scatter(x_data, y_data [, label=]) # Or: plt.plot(y_data) plt.legend() # Adds a legend. +plt.title/xlabel/ylabel() # Adds a title/labels. plt.savefig() # Saves the figure. plt.show() # Displays the figure. plt.clf() # Clears the figure. diff --git a/index.html b/index.html index 076d52d..43a4dff 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1334,7 +1334,7 @@ p.add_argument('<name>', type=<type>

Modes

  • 'r' - Read (default).
  • -
  • 'w' - Write (truncate).
  • +
  • 'w' - Write (truncate, i.e. delete existing contents).
  • 'x' - Write or fail if the file already exists.
  • 'a' - Append.
  • 'w+' - Read and write (truncate).
  • @@ -1695,12 +1695,12 @@ CompletedProcess(args=['bc', # Appends items from the binary file.
    <bytes> = bytes(<array>)                       # Returns a copy of array's memory.
    -<file>.write(<array>)                          # Writes array to the binary file.
    +<file>.write(<array>)                          # Writes array's memory to the 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.
    -<real>  = <mview>[index]                       # Returns an int or a float.
    +<obj>   = <mview>[index]                       # Returns int, float or bytes ('c' format).
     <mview> = <mview>[<slice>]                     # Returns mview with rearranged elements.
    -<mview> = <mview>.cast('<typecode>')           # Only works between b/B/c and other types.
    +<mview> = <mview>.cast('<typecode>')           # Only works between B/b/c and other types.
     <mview>.release()                              # Releases memory buffer of the base object.
     
    @@ -1708,9 +1708,9 @@ 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 mview to the binary file. +<file>.write(<mview>) # Writes `bytes(<mview>)` to the file. -
    <list>  = list(<mview>)                        # Returns a list of ints or floats.
    +
    <list>  = list(<mview>)                        # Returns a list of ints, floats or bytes.
     <str>   = str(<mview>, 'utf-8')                # Treats mview as a bytes object.
     <str>   = <mview>.hex()                        # Returns hex pairs. Accepts `sep=<str>`.
     
    @@ -1980,6 +1980,7 @@ Processing: 100%|████████████████████| 3 plt.plot/bar/scatter(x_data, y_data [, label=<str>]) # Or: plt.plot(y_data) plt.legend() # Adds a legend. +plt.title/xlabel/ylabel(<str>) # Adds a title/labels. plt.savefig(<path>) # Saves the figure. plt.show() # Displays the figure. plt.clf() # Clears the figure. @@ -2932,7 +2933,7 @@ $ deactivate # Deactivates the activ