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

Black reformat

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