Skip to content

Commit 02bde17

Browse files
committed
Some copyediting changes
1 parent c4a8475 commit 02bde17

File tree

11 files changed

+130
-128
lines changed

11 files changed

+130
-128
lines changed

Impressionist/impressionist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,5 @@ def create_output(self, out_file: str, height: int, vector: bool, animation_leng
166166
if animation_frames is not None:
167167
animation_frames[0].save(out_file + ".gif", save_all=True,
168168
append_images=animation_frames[1:], optimize=False,
169-
duration=animation_length, loop=0, transparency=0, disposal=2)
169+
duration=animation_length, loop=0,
170+
transparency=0, disposal=2)

KNN/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run():
3636
digits_file = (Path(__file__).resolve().parent
3737
/ "datasets" / "digits" / "digits.csv")
3838
digits_knn = KNN(Digit, digits_file, has_header=False)
39-
# Startup Pygame, create the window
39+
# Start up Pygame, create the window
4040
pygame.init()
4141
screen = pygame.display.set_mode(size=(PIXEL_WIDTH, PIXEL_HEIGHT),
4242
flags=pygame.SCALED | pygame.RESIZABLE)
@@ -59,7 +59,8 @@ def run():
5959
pixels = digit_pixels.transpose((1, 0, 2))[:, :, 0].flatten() * P_TO_D
6060
predicted_pixels = digits_knn.predict_array(K, Digit("", pixels), "pixels")
6161
predicted_pixels = predicted_pixels.reshape((PIXEL_HEIGHT, PIXEL_WIDTH)).transpose((1, 0)) * D_TO_P
62-
digit_pixels = np.stack((predicted_pixels, predicted_pixels, predicted_pixels), axis=2)
62+
digit_pixels = np.stack((predicted_pixels, predicted_pixels,
63+
predicted_pixels), axis=2)
6364
# Handle mouse events
6465
elif ((event.type == pygame.MOUSEBUTTONDOWN) or
6566
(event.type == pygame.MOUSEMOTION and pygame.mouse.get_pressed()[0])):

KNN/knn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ def classify(self, k: int, data_point: DP) -> str:
5656
neighbors = self.nearest(k, data_point)
5757
return Counter(neighbor.kind for neighbor in neighbors).most_common(1)[0][0]
5858

59-
# Predict a numeric property of a data point based on the k nearest neighbors
60-
# Find the average of that property from the neighbors and return it
59+
# Predict a numeric property of a data point based on the k-nearest neighbors.
60+
# Find the average of that property from the neighbors and return it.
6161
def predict(self, k: int, data_point: DP, property_name: str) -> float:
6262
neighbors = self.nearest(k, data_point)
6363
return (sum([getattr(neighbor, property_name) for neighbor in neighbors])
6464
/ len(neighbors))
6565

66-
# Predict a NumPy array property of a data point based on the k nearest neighbors
67-
# Find the average of that property from the neighbors and return it
66+
# Predict a NumPy array property of a data point based on the k-nearest neighbors.
67+
# Find the average of that property from the neighbors and return it.
6868
def predict_array(self, k: int, data_point: DP, property_name: str) -> np.ndarray:
6969
neighbors = self.nearest(k, data_point)
7070
return (np.sum([getattr(neighbor, property_name) for neighbor in neighbors], axis=0)

0 commit comments

Comments
 (0)