A community-maintained Python framework for creating mathematical animations.
Random fixes to old_projects
Grant Sanderson6ab8f7f7fc22
diff --git a/old_projects/WindingNumber_G.py b/old_projects/WindingNumber_G.pyindex c891fb3d8..817cbcc38 100644--- a/old_projects/WindingNumber_G.py+++ b/old_projects/WindingNumber_G.py@@ -2351,6 +2351,7 @@ class TransitionFromPathsToBoundariesArrowless(TransitionFromPathsToBoundaries):class BreakDownLoopWithNonzeroWinding(TransitionFromPathsToBoundaries):def construct(self):+ TransitionFromPathsToBoundaries.construct(self)zero_point = 2*LEFTsquares, joint_rect = self.get_squares_and_joint_rect()diff --git a/old_projects/brachistochrone/cycloid.py b/old_projects/brachistochrone/cycloid.pyindex fd62497d0..ef624126a 100644--- a/old_projects/brachistochrone/cycloid.py+++ b/old_projects/brachistochrone/cycloid.py@@ -337,7 +337,7 @@ class LeviSolution(CycloidScene):new_theta.next_to(new_arc, LEFT)new_theta.shift(0.1*DOWN)kwargs = {- "stroke_width" : 2*DEFAULT_POINT_THICKNESS,+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH,}triangle1 = Polygon(self.p_point, self.c_point, self.bottom_point,diff --git a/old_projects/complex_multiplication_article.py b/old_projects/complex_multiplication_article.pyindex 18c445e51..656411d81 100644--- a/old_projects/complex_multiplication_article.py+++ b/old_projects/complex_multiplication_article.py@@ -9,7 +9,7 @@ from big_ol_pile_of_manim_imports import *from functools import reduceDEFAULT_PLANE_CONFIG = {- "stroke_width" : 2*DEFAULT_POINT_THICKNESS+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH}diff --git a/old_projects/matrix_as_transform_2d.py b/old_projects/matrix_as_transform_2d.pyindex 4bd7176fb..bf03ea974 100644--- a/old_projects/matrix_as_transform_2d.py+++ b/old_projects/matrix_as_transform_2d.py@@ -7,7 +7,7 @@ import sysfrom big_ol_pile_of_manim_imports import *-ARROW_CONFIG = {"stroke_width" : 2*DEFAULT_POINT_THICKNESS}+ARROW_CONFIG = {"stroke_width" : 2*DEFAULT_STROKE_WIDTH}LIGHT_RED = RED_Edef matrix_to_string(matrix):@@ -52,7 +52,7 @@ class ShowMultiplication(NumberLineScene):def construct(self, num, show_original_line):config = {"density" : max(abs(num), 1)*DEFAULT_POINT_DENSITY_1D,- "stroke_width" : 2*DEFAULT_POINT_THICKNESS+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH}if abs(num) < 1:config["numerical_radius"] = FRAME_X_RADIUS/num@@ -115,7 +115,7 @@ class ExamplesOfNonlinearOneDimensionalTransforms(NumberLineScene):self.clear()self.add(self.nonlinear)config = {- "stroke_width" : 2*DEFAULT_POINT_THICKNESS,+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH,"density" : 5*DEFAULT_POINT_DENSITY_1D,}NumberLineScene.construct(self, **config)@@ -144,7 +144,7 @@ class ShowTwoThenThree(ShowMultiplication):def construct(self):config = {- "stroke_width" : 2*DEFAULT_POINT_THICKNESS,+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH,"density" : 6*DEFAULT_POINT_DENSITY_1D,}NumberLineScene.construct(self, **config)@@ -163,7 +163,7 @@ class TransformScene2D(Scene):"x_radius" : FRAME_WIDTH,"y_radius" : FRAME_WIDTH,"density" : DEFAULT_POINT_DENSITY_1D*density_factor,- "stroke_width" : 2*DEFAULT_POINT_THICKNESS+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH}if not use_faded_lines:config["x_faded_line_frequency"] = None@@ -323,7 +323,7 @@ class ExamplesOfNonlinearTwoDimensionalTransformations(Scene):"x_radius" : FRAME_WIDTH,"y_radius" : FRAME_WIDTH,"density" : 3*DEFAULT_POINT_DENSITY_1D,- "stroke_width" : 2*DEFAULT_POINT_THICKNESS+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH}number_plane = NumberPlane(**config)numbers = number_plane.get_coordinate_labels()@@ -377,7 +377,7 @@ class TrickyExamplesOfNonlinearTwoDimensionalTransformations(Scene):"x_radius" : 0.6*FRAME_WIDTH,"y_radius" : 0.6*FRAME_WIDTH,"density" : 10*DEFAULT_POINT_DENSITY_1D,- "stroke_width" : 2*DEFAULT_POINT_THICKNESS+ "stroke_width" : 2*DEFAULT_STROKE_WIDTH}number_plane = NumberPlane(**config)phrase1, phrase2 = TextMobject([diff --git a/old_projects/nn/image_map b/old_projects/nn/image_mapindex ca5133bbc..88d8277f0 100644Binary files a/old_projects/nn/image_map and b/old_projects/nn/image_map differdiff --git a/old_projects/nn/mnist_loader.py b/old_projects/nn/mnist_loader.pyindex 74e6360fb..f05bc29f3 100644--- a/old_projects/nn/mnist_loader.py+++ b/old_projects/nn/mnist_loader.py@@ -40,7 +40,11 @@ def load_data():below."""f = gzip.open('/Users/grant/cs/neural-networks-and-deep-learning/data/mnist.pkl.gz', 'rb')- training_data, validation_data, test_data = pickle.load(f)+ u = pickle._Unpickler(f)+ u.encoding = 'latin1'+ # p = u.load()+ # training_data, validation_data, test_data = pickle.load(f)+ training_data, validation_data, test_data = u.load()f.close()return (training_data, validation_data, test_data)diff --git a/old_projects/nn/network.py b/old_projects/nn/network.pyindex b8386028b..392ad01d1 100644--- a/old_projects/nn/network.py+++ b/old_projects/nn/network.py@@ -165,8 +165,8 @@ class Network(object):return sum(int(x == y) for (x, y) in test_results)def cost_derivative(self, output_activations, y):- """Return the vector of partial derivatives \partial C_x /- \partial a for the output activations."""+ """Return the vector of partial derivatives \\partial C_x /+ \\partial a for the output activations."""return (output_activations-y)#### Miscellaneous functions@@ -195,8 +195,8 @@ def ReLU_prime(z):return (np.array(z) > 0).astype('int')def get_pretrained_network():- data_file = open(PRETRAINED_DATA_FILE)- weights, biases = pickle.load(data_file)+ data_file = open(PRETRAINED_DATA_FILE, 'rb')+ weights, biases = pickle.load(data_file, encoding='latin1')sizes = [w.shape[1] for w in weights]sizes.append(weights[-1].shape[0])network = Network(sizes)@@ -275,13 +275,13 @@ def save_organized_images(n_images_per_number = 10):if len(image_map[value]) >= n_images_per_number:continueimage_map[value].append(im)- data_file = open(IMAGE_MAP_DATA_FILE, mode = 'w')+ data_file = open(IMAGE_MAP_DATA_FILE, mode = 'wb')pickle.dump(image_map, data_file)data_file.close()def get_organized_images():data_file = open(IMAGE_MAP_DATA_FILE, mode = 'r')- image_map = pickle.load(data_file)+ image_map = pickle.load(data_file, encoding='latin1')data_file.close()return image_mapdiff --git a/old_projects/nn/part1.py b/old_projects/nn/part1.pyindex a1123bd95..00e0d5e32 100644--- a/old_projects/nn/part1.py+++ b/old_projects/nn/part1.py@@ -144,10 +144,10 @@ class NetworkMobject(VGroup):if size > n_neurons:dots = TexMobject("\\vdots")dots.move_to(neurons)- VGroup(*neurons[:len(neurons)/2]).next_to(+ VGroup(*neurons[:len(neurons) // 2]).next_to(dots, UP, MED_SMALL_BUFF)- VGroup(*neurons[len(neurons)/2:]).next_to(+ VGroup(*neurons[len(neurons) // 2:]).next_to(dots, DOWN, MED_SMALL_BUFF)layer.dots = dotsdiff --git a/old_projects/wcat.py b/old_projects/wcat.pyindex d04ba6e53..30b670c96 100644--- a/old_projects/wcat.py+++ b/old_projects/wcat.py@@ -453,7 +453,7 @@ class DefineInscribedSquareProblem(ClosedLoopScene):pi_loop.set_fill(opacity = 0)pi_loop.set_stroke(color = WHITE,- width = DEFAULT_POINT_THICKNESS+ width = DEFAULT_STROKE_WIDTH)pi_loop.set_height(4)randy = Randolph()