Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mikes zhang
001
提交
76fd6e5f
0
001
项目概览
mikes zhang
/
001
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
0
001
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
76fd6e5f
编写于
10月 26, 2020
作者:
D
Dan Bader
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Black reformat
上级
809b5bf7
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
126 addition
and
122 deletion
+126
-122
arcade-a-primer/arcade_basic_oop.py
arcade-a-primer/arcade_basic_oop.py
+3
-6
arcade-a-primer/arcade_draw_shapes.py
arcade-a-primer/arcade_draw_shapes.py
+3
-6
arcade-a-primer/arcade_game.py
arcade-a-primer/arcade_game.py
+3
-6
intro-to-threading/prodcom_event.py
intro-to-threading/prodcom_event.py
+1
-2
intro-to-threading/prodcom_lock.py
intro-to-threading/prodcom_lock.py
+1
-2
pandas-gradebook-project/02-merging-dataframes.py
pandas-gradebook-project/02-merging-dataframes.py
+4
-1
pandas-gradebook-project/03-calculating-grades.py
pandas-gradebook-project/03-calculating-grades.py
+4
-1
pandas-gradebook-project/04-grouping-the-data.py
pandas-gradebook-project/04-grouping-the-data.py
+4
-1
pandas-gradebook-project/05-plotting-summary-statistics.py
pandas-gradebook-project/05-plotting-summary-statistics.py
+4
-1
pandas-gradebook-project/06-final-gradebook.py
pandas-gradebook-project/06-final-gradebook.py
+4
-1
storing-images/storing_images.py
storing-images/storing_images.py
+95
-95
未找到文件。
arcade-a-primer/arcade_basic_oop.py
浏览文件 @
76fd6e5f
...
...
@@ -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
()
...
...
arcade-a-primer/arcade_draw_shapes.py
浏览文件 @
76fd6e5f
...
...
@@ -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
()
...
...
arcade-a-primer/arcade_game.py
浏览文件 @
76fd6e5f
...
...
@@ -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
()
...
...
intro-to-threading/prodcom_event.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
intro-to-threading/prodcom_lock.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
pandas-gradebook-project/02-merging-dataframes.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
pandas-gradebook-project/03-calculating-grades.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
pandas-gradebook-project/04-grouping-the-data.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
pandas-gradebook-project/05-plotting-summary-statistics.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
pandas-gradebook-project/06-final-gradebook.py
浏览文件 @
76fd6e5f
...
...
@@ -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
...
...
storing-images/storing_images.py
浏览文件 @
76fd6e5f
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录