From 3367ba55ba03e8c3413510e36d42155cb82d44bf Mon Sep 17 00:00:00 2001 From: Margaret Matocha Date: Wed, 22 Jul 2020 12:07:32 -0500 Subject: [PATCH] Updated examples for pylint --- .../display_shapes_sparkline_simpletest.py | 34 ++++++++------ examples/display_shapes_sparkline_ticks.py | 23 ++++++---- examples/display_shapes_sparkline_triple.py | 45 +++++++++++-------- 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/examples/display_shapes_sparkline_simpletest.py b/examples/display_shapes_sparkline_simpletest.py index 4a4d9e8..7fafd6a 100755 --- a/examples/display_shapes_sparkline_simpletest.py +++ b/examples/display_shapes_sparkline_simpletest.py @@ -4,14 +4,18 @@ # See the bottom for a code example using the `sparkline` Class. # # File: display_shapes_sparkline.py -# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted. +# A sparkline is a scrolling line graph, where any values added to sparkline using +# `add_value` are plotted. # -# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)` +# The `sparkline` class creates an element suitable for adding to the display using +# `display.show(mySparkline)` # or adding to a `displayio.Group` to be displayed. # -# When creating the sparkline, identify the number of `max_items` that will be included in the graph. -# When additional elements are added to the sparkline and the number of items has exceeded max_items, -# any excess values are removed from the left of the graph, and new values are added to the right. +# When creating the sparkline, identify the number of `max_items` that will be +# included in the graph. +# When additional elements are added to the sparkline and the number of items has +# exceeded max_items, any excess values are removed from the left of the graph, +# and new values are added to the right. # The following is an example that shows the @@ -23,11 +27,12 @@ # add new values to sparkline `add_value` # update the sparklines `update` +import time +import random import board import displayio -import terminalio -import random -import time + + from adafruit_display_shapes.sparkline import Sparkline if "DISPLAY" not in dir(board): @@ -47,7 +52,7 @@ while not spi.try_lock(): spi.configure(baudrate=32000000) - pass + spi.unlock() display_bus = displayio.FourWire( @@ -90,15 +95,18 @@ chartWidth = display.width chartHeight = display.height -# mySparkline1 uses a vertical y range between 0 to 10 and will contain a maximum of 40 items +# mySparkline1 uses a vertical y range between 0 to 10 and will contain a +# maximum of 40 items mySparkline1 = Sparkline( width=chartWidth, height=chartHeight, max_items=40, yMin=0, yMax=10, x=0, y=0 ) -# Create a group to hold the sparkline and append the sparkline into the group (myGroup) +# Create a group to hold the sparkline and append the sparkline into the +# group (myGroup) # -# Note: In cases where display elements will overlap, then the order the elements are added to the -# group will set which is on top. Latter elements are displayed on top of former elemtns. +# Note: In cases where display elements will overlap, then the order the elements +# are added to the group will set which is on top. Latter elements are displayed +# on top of former elemtns. myGroup = displayio.Group(max_size=1) # add the sparkline into myGroup diff --git a/examples/display_shapes_sparkline_ticks.py b/examples/display_shapes_sparkline_ticks.py index 88cbb71..e34bf81 100755 --- a/examples/display_shapes_sparkline_ticks.py +++ b/examples/display_shapes_sparkline_ticks.py @@ -4,14 +4,17 @@ # See the bottom for a code example using the `sparkline` Class. # # File: display_shapes_sparkline.py -# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted. +# A sparkline is a scrolling line graph, where any values added to sparkline +# using `add_value` are plotted. # -# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)` -# or adding to a `displayio.Group` to be displayed. +# The `sparkline` class creates an element suitable for adding to the display +# using `display.show(mySparkline)` or adding to a `displayio.Group` to be displayed. # -# When creating the sparkline, identify the number of `max_items` that will be included in the graph. -# When additional elements are added to the sparkline and the number of items has exceeded max_items, -# any excess values are removed from the left of the graph, and new values are added to the right. +# When creating the sparkline, identify the number of `max_items` that will be +# included in the graph. +# When additional elements are added to the sparkline and the number of items +# has exceeded max_items, any excess values are removed from the left of the +# graph, and new values are added to the right. # The following is an example that shows the @@ -100,7 +103,8 @@ # Setup the first bitmap and sparkline # This sparkline has no background bitmap -# mySparkline1 uses a vertical y range between 0 to 10 and will contain a maximum of 40 items +# mySparkline1 uses a vertical y range between 0 to 10 and will contain a +# maximum of 40 items mySparkline1 = Sparkline( width=chartWidth, height=chartHeight, @@ -142,8 +146,9 @@ # Create a group to hold the sparkline, text, rectangle and tickmarks # append them into the group (myGroup) # -# Note: In cases where display elements will overlap, then the order the elements are added to the -# group will set which is on top. Latter elements are displayed on top of former elemtns. +# Note: In cases where display elements will overlap, then the order the +# elements are added to the group will set which is on top. Latter elements +# are displayed on top of former elemtns. myGroup = displayio.Group(max_size=20) diff --git a/examples/display_shapes_sparkline_triple.py b/examples/display_shapes_sparkline_triple.py index d83a4a7..e15f3c1 100755 --- a/examples/display_shapes_sparkline_triple.py +++ b/examples/display_shapes_sparkline_triple.py @@ -4,14 +4,17 @@ # See the bottom for a code example using the `sparkline` Class. # # File: display_shapes_sparkline.py -# A sparkline is a scrolling line graph, where any values added to sparkline using `add_value` are plotted. +# A sparkline is a scrolling line graph, where any values added to sparkline +# using `add_value` are plotted. # -# The `sparkline` class creates an element suitable for adding to the display using `display.show(mySparkline)` -# or adding to a `displayio.Group` to be displayed. +# The `sparkline` class creates an element suitable for adding to the display +# using `display.show(mySparkline)` or adding to a `displayio.Group` to be displayed. # -# When creating the sparkline, identify the number of `max_items` that will be included in the graph. -# When additional elements are added to the sparkline and the number of items has exceeded max_items, -# any excess values are removed from the left of the graph, and new values are added to the right. +# When creating the sparkline, identify the number of `max_items` that will be +# included in the graph. +# When additional elements are added to the sparkline and the number of items +# has exceeded max_items, any excess values are removed from the left of the +# graph, and new values are added to the right. # The following is an example that shows the @@ -23,11 +26,11 @@ # add new values to sparkline `add_value` # update the sparklines `update` +import random +import time import board import displayio import terminalio -import random -import time from adafruit_display_shapes.sparkline import Sparkline from adafruit_ili9341 import ILI9341 from adafruit_display_text import label @@ -75,7 +78,7 @@ display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, - rotation=180, # The rotation can be adjusted to match your configuration. + rotation=180, # The rotation can be adjusted to match your configuration. auto_refresh=True, native_frames_per_second=90, ) @@ -124,7 +127,8 @@ # Setup the second bitmap and sparkline -# mySparkline2 uses a vertical y range between 0 to 1, and will contain a maximum of 10 items +# mySparkline2 uses a vertical y range between 0 to 1, and will contain a +# maximum of 10 items # palette2 = displayio.Palette(1) # color palette used for bitmap2 (one color) palette2[0] = 0x0000FF @@ -147,9 +151,12 @@ # Setup the third bitmap and third sparkline # mySparkline3 contains a maximum of 10 items -# since yMin and yMax are not specified, mySparkline3 uses autoranging for both the top and bottom of the y-axis. -# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based on the data in the list. -# Note2: You can read back the value of the y-axis limits by using mySparkline3.yBottom or mySparkline3.yTop +# since yMin and yMax are not specified, mySparkline3 uses autoranging for both +# the top and bottom of the y-axis. +# Note1: Any unspecified edge limit (yMin or yMax) will autorange that edge based +# on the data in the list. +# Note2: You can read back the value of the y-axis limits by using +# mySparkline3.yBottom or mySparkline3.yTop palette3 = displayio.Palette(1) # color palette used for bitmap (one color) @@ -187,12 +194,12 @@ 120 + mySparkline3.height, ) # set the text anchored position to the upper right of the graph - # Create a group to hold the three bitmap TileGrids and the three sparklines and # append them into the group (myGroup) # -# Note: In cases where display elements will overlap, then the order the elements are added to the -# group will set which is on top. Latter elements are displayed on top of former elemtns. +# Note: In cases where display elements will overlap, then the order the elements +# are added to the group will set which is on top. Latter elements are displayed +# on top of former elemtns. myGroup = displayio.Group(max_size=20) myGroup.append(mySparkline1) @@ -207,7 +214,8 @@ myGroup.append(textLabel3a) myGroup.append(textLabel3b) -# Set the display to show myGroup that contains all the bitmap TileGrids and sparklines +# Set the display to show myGroup that contains all the bitmap TileGrids and +# sparklines display.show(myGroup) i = 0 # This is a counter for changing the random values for mySparkline3 @@ -227,7 +235,8 @@ # Note: For mySparkline2, the y-axis range is set from 0 to 1. # With the random values set between -1 and +2, the values will sometimes # be out of the y-range. This example shows how the fixed y-range (0 to 1) - # will "clip" values (it will not display them) that are above or below the y-range. + # will "clip" values (it will not display them) that are above or below the + # y-range. mySparkline2.add_value(random.uniform(-1, 2)) # mySparkline3 is set autoranging for the top and bottom of the Y-axis