提交 76fd6e5f 编写于 作者: D Dan Bader

Black reformat

上级 809b5bf7
......@@ -14,12 +14,10 @@ RADIUS = 150
class Welcome(arcade.Window):
"""Our main welcome window
"""
"""Our main welcome window"""
def __init__(self):
"""Initialize the window
"""
"""Initialize the window"""
# Call the parent class constructor
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
......@@ -28,8 +26,7 @@ class Welcome(arcade.Window):
arcade.set_background_color(arcade.color.WHITE)
def on_draw(self):
"""Called whenever we need to draw our window
"""
"""Called whenever we need to draw our window"""
# Clear the screen and start drawing
arcade.start_render()
......
......@@ -13,12 +13,10 @@ SCREEN_TITLE = "Draw Shapes"
class Welcome(arcade.Window):
"""Our main welcome window
"""
"""Our main welcome window"""
def __init__(self):
"""Initialize the window
"""
"""Initialize the window"""
# Call the parent class constructor
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
......@@ -27,8 +25,7 @@ class Welcome(arcade.Window):
arcade.set_background_color(arcade.color.WHITE)
def on_draw(self):
"""Called whenever we need to draw our window
"""
"""Called whenever we need to draw our window"""
# Clear the screen and start drawing
arcade.start_render()
......
......@@ -41,8 +41,7 @@ class SpaceShooter(arcade.Window):
"""
def __init__(self, width: int, height: int, title: str):
"""Initialize the game
"""
"""Initialize the game"""
super().__init__(width, height, title)
# Setup the empty sprite lists
......@@ -51,8 +50,7 @@ class SpaceShooter(arcade.Window):
self.all_sprites = arcade.SpriteList()
def setup(self):
"""Get the game ready to play
"""
"""Get the game ready to play"""
# Set the background color
arcade.set_background_color(arcade.color.SKY_BLUE)
......@@ -236,8 +234,7 @@ class SpaceShooter(arcade.Window):
self.player.left = 0
def on_draw(self):
"""Draw all game objects
"""
"""Draw all game objects"""
arcade.start_render()
self.all_sprites.draw()
......
......@@ -7,8 +7,7 @@ import time
class Pipeline:
"""Class to allow a single element pipeline between producer and consumer.
"""
"""Class to allow a single element pipeline between producer and consumer."""
def __init__(self):
self.value = 0
......
......@@ -8,8 +8,7 @@ SENTINEL = object()
class Pipeline:
"""Class to allow a single element pipeline between producer and consumer.
"""
"""Class to allow a single element pipeline between producer and consumer."""
def __init__(self):
self.message = 0
......
......@@ -48,7 +48,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -49,7 +49,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -49,7 +49,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -51,7 +51,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
# ------------------------
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -43,7 +43,10 @@ for file_path in DATA_FOLDER.glob("quiz_*_grades.csv"):
quiz_grades = pd.concat([quiz_grades, quiz], axis=1)
final_data = pd.merge(
roster, hw_exam_grades, left_index=True, right_index=True,
roster,
hw_exam_grades,
left_index=True,
right_index=True,
)
final_data = pd.merge(
final_data, quiz_grades, left_on="Email Address", right_index=True
......
......@@ -85,12 +85,12 @@ class CIFAR_Image:
def store_single_disk(image, image_id, label):
""" Stores a single image as a .png file on disk.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image as a .png file on disk.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
Image.fromarray(image).save(disk_dir / f"{image_id}.png")
......@@ -102,12 +102,12 @@ def store_single_disk(image, image_id, label):
def store_single_lmdb(image, image_id, label):
""" Stores a single image to a LMDB.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image to a LMDB.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
map_size = image.nbytes * 10
......@@ -125,12 +125,12 @@ def store_single_lmdb(image, image_id, label):
def store_single_hdf5(image, image_id, label):
""" Stores a single image to an HDF5 file.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""Stores a single image to an HDF5 file.
Parameters:
---------------
image image array, (32, 32, 3) to be stored
image_id integer unique ID for image
label image label
"""
# Create a new HDF5 file
......@@ -164,11 +164,11 @@ for method in ("disk", "lmdb", "hdf5"):
def store_many_disk(images, labels):
""" Stores an array of images to disk
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to disk
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -188,11 +188,11 @@ def store_many_disk(images, labels):
def store_many_lmdb(images, labels):
""" Stores an array of images to LMDB.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to LMDB.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -212,11 +212,11 @@ def store_many_lmdb(images, labels):
def store_many_hdf5(images, labels):
""" Stores an array of images to HDF5.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""Stores an array of images to HDF5.
Parameters:
---------------
images images array, (N, 32, 32, 3) to be stored
labels labels array, (N, 1) to be stored
"""
num_images = len(images)
......@@ -270,14 +270,14 @@ for cutoff in cutoffs:
def plot_with_legend(
x_range, y_data, legend_labels, x_label, y_label, title, log=False
):
""" Displays a single plot with multiple datasets and matching legends.
Parameters:
--------------
x_range list of lists containing x data
y_data list of lists containing y values
legend_labels list of string legend labels
x_label x axis label
y_label y axis label
"""Displays a single plot with multiple datasets and matching legends.
Parameters:
--------------
x_range list of lists containing x data
y_data list of lists containing y values
legend_labels list of string legend labels
x_label x axis label
y_label y axis label
"""
plt.style.use("seaborn-whitegrid")
plt.figure(figsize=(10, 7))
......@@ -362,15 +362,15 @@ plt.show()
def read_single_disk(image_id):
""" Stores a single image to disk.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to disk.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
image = np.array(Image.open(disk_dir / f"{image_id}.png"))
......@@ -384,15 +384,15 @@ def read_single_disk(image_id):
def read_single_lmdb(image_id):
""" Stores a single image to LMDB.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to LMDB.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
# Open the LMDB environment; see (1)
......@@ -413,15 +413,15 @@ def read_single_lmdb(image_id):
def read_single_hdf5(image_id):
""" Stores a single image to HDF5.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""Stores a single image to HDF5.
Parameters:
---------------
image_id integer unique ID for image
Returns:
----------
image image array, (32, 32, 3) to be stored
label associated meta data, int label
"""
# Open the HDF5 file
......@@ -454,15 +454,15 @@ for method in ("disk", "lmdb", "hdf5"):
def read_many_disk(num_images):
""" Reads image from disk.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from disk.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
......@@ -480,15 +480,15 @@ def read_many_disk(num_images):
def read_many_lmdb(num_images):
""" Reads image from LMDB.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from LMDB.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
env = lmdb.open(str(lmdb_dir / f"{num_images}_lmdb"), readonly=True)
......@@ -509,15 +509,15 @@ def read_many_lmdb(num_images):
def read_many_hdf5(num_images):
""" Reads image from HDF5.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""Reads image from HDF5.
Parameters:
---------------
num_images number of images to read
Returns:
----------
images images array, (N, 32, 32, 3) to be stored
labels associated meta data, int label (N, 1)
"""
images, labels = [], []
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册