mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Change "print " lines to "print(" lines
This commit is contained in:
parent
5c1a8f9a32
commit
384915d5a7
9 changed files with 188 additions and 305 deletions
|
@ -44,7 +44,7 @@ def get_configuration(sys_argv):
|
|||
try:
|
||||
opts, args = getopt.getopt(sys_argv[1:], 'hlmpwstqao:')
|
||||
except getopt.GetoptError as err:
|
||||
print str(err)
|
||||
print(str(err))
|
||||
sys.exit(2)
|
||||
config = {
|
||||
"file" : None,
|
||||
|
@ -63,7 +63,7 @@ def get_configuration(sys_argv):
|
|||
}
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print HELP_MESSAGE
|
||||
print(HELP_MESSAGE)
|
||||
return
|
||||
if opt in ['-l', '-p']:
|
||||
config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG
|
||||
|
@ -93,7 +93,7 @@ def get_configuration(sys_argv):
|
|||
config["skip_animations"] = config["save_image"] and not config["write_to_movie"]
|
||||
|
||||
if len(args) == 0:
|
||||
print HELP_MESSAGE
|
||||
print(HELP_MESSAGE)
|
||||
sys.exit()
|
||||
config["file"] = args[0]
|
||||
if len(args) > 1:
|
||||
|
@ -129,7 +129,7 @@ def prompt_user_for_choice(name_to_obj):
|
|||
num_to_name = {}
|
||||
names = sorted(name_to_obj.keys())
|
||||
for count, name in zip(it.count(1), names):
|
||||
print "%d: %s"%(count, name)
|
||||
print("%d: %s"%(count, name))
|
||||
num_to_name[count] = name
|
||||
try:
|
||||
user_input = raw_input(CHOOSE_NUMBER_MESSAGE)
|
||||
|
@ -138,19 +138,19 @@ def prompt_user_for_choice(name_to_obj):
|
|||
for num_str in user_input.split(",")
|
||||
]
|
||||
except:
|
||||
print INVALID_NUMBER_MESSAGE
|
||||
print(INVALID_NUMBER_MESSAGE)
|
||||
sys.exit()
|
||||
|
||||
def get_scene_classes(scene_names_to_classes, config):
|
||||
if len(scene_names_to_classes) == 0:
|
||||
print NO_SCENE_MESSAGE
|
||||
print(NO_SCENE_MESSAGE)
|
||||
return []
|
||||
if len(scene_names_to_classes) == 1:
|
||||
return scene_names_to_classes.values()
|
||||
if config["scene_name"] in scene_names_to_classes:
|
||||
return [scene_names_to_classes[config["scene_name"]] ]
|
||||
if config["scene_name"] != "":
|
||||
print SCENE_NOT_FOUND_MESSAGE
|
||||
print(SCENE_NOT_FOUND_MESSAGE)
|
||||
return []
|
||||
if config["write_all"]:
|
||||
return scene_names_to_classes.values()
|
||||
|
@ -206,15 +206,11 @@ def main():
|
|||
handle_scene(SceneClass(**scene_kwargs), **config)
|
||||
play_finish_sound()
|
||||
except:
|
||||
print "\n\n"
|
||||
print("\n\n")
|
||||
traceback.print_exc()
|
||||
print "\n\n"
|
||||
print("\n\n")
|
||||
play_error_sound()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -284,9 +284,9 @@ def generate_tex_file(expression, template_tex_file):
|
|||
tex_hash(expression, template_tex_file)
|
||||
) + ".tex"
|
||||
if not os.path.exists(result):
|
||||
print "Writing \"%s\" to %s"%(
|
||||
print("Writing \"%s\" to %s"%(
|
||||
"".join(expression), result
|
||||
)
|
||||
))
|
||||
with open(template_tex_file, "r") as infile:
|
||||
body = infile.read()
|
||||
body = body.replace(TEX_TEXT_TO_REPLACE, expression)
|
||||
|
@ -345,17 +345,3 @@ def dvi_to_svg(dvi_file, regen_if_exists = False):
|
|||
]
|
||||
os.system(" ".join(commands))
|
||||
return result
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -92,10 +92,10 @@ class Network(object):
|
|||
for mini_batch in mini_batches:
|
||||
self.update_mini_batch(mini_batch, eta)
|
||||
if test_data:
|
||||
print "Epoch {0}: {1} / {2}".format(
|
||||
j, self.evaluate(test_data), n_test)
|
||||
print("Epoch {0}: {1} / {2}".format(
|
||||
j, self.evaluate(test_data), n_test))
|
||||
else:
|
||||
print "Epoch {0} complete".format(j)
|
||||
print("Epoch {0} complete".format(j))
|
||||
|
||||
def update_mini_batch(self, mini_batch, eta):
|
||||
"""Update the network's weights and biases by applying
|
||||
|
@ -215,7 +215,7 @@ def test_network():
|
|||
n_right += 1
|
||||
else:
|
||||
n_wrong += 1
|
||||
print n_right, n_wrong, float(n_right)/(n_right + n_wrong)
|
||||
print(n_right, n_wrong, float(n_right)/(n_right + n_wrong))
|
||||
|
||||
def layer_to_image_array(layer):
|
||||
w = int(np.ceil(np.sqrt(len(layer))))
|
||||
|
@ -254,8 +254,8 @@ def maximizing_input(network, layer_index, layer_vect, n_steps = 100, seed_guess
|
|||
norms.append(norm)
|
||||
old_pre_sig_guess = np.array(pre_sig_guess)
|
||||
pre_sig_guess += 0.1*gradient
|
||||
print np.linalg.norm(old_pre_sig_guess - pre_sig_guess)
|
||||
print ""
|
||||
print(np.linalg.norm(old_pre_sig_guess - pre_sig_guess))
|
||||
print("")
|
||||
return sigmoid(pre_sig_guess)
|
||||
|
||||
def save_organized_images(n_images_per_number = 10):
|
||||
|
@ -299,41 +299,3 @@ def get_organized_images():
|
|||
# prev_vect /= np.max(np.abs(prev_vect))
|
||||
# # prev_vect /= 1.1
|
||||
# return maximizing_input(network, layer_index - 1, prev_vect)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ def get_hand_map(which_hand = "right"):
|
|||
elif which_hand == "left":
|
||||
Class = LeftHand
|
||||
else:
|
||||
print "Bad arg, bro"
|
||||
print("Bad arg, bro")
|
||||
return
|
||||
return dict([
|
||||
(num, Class(num, small=True))
|
||||
|
@ -170,7 +170,7 @@ class SaveEachNumber(OverHand):
|
|||
Image.fromarray(self.frames[COUNT_TO_FRAME_NUM[count]]).save(path)
|
||||
|
||||
def write_to_movie(self, name = None):
|
||||
print "Why bother writing to movie..."
|
||||
print("Why bother writing to movie...")
|
||||
|
||||
class ShowCounting(OverHand):
|
||||
def construct(self):
|
||||
|
@ -197,7 +197,7 @@ class ShowFrameNum(OverHand):
|
|||
def construct(self):
|
||||
OverHand.construct(self)
|
||||
for frame, count in zip(self.frames, it.count()):
|
||||
print count, "of", len(self.frames)
|
||||
print(count + "of" + len(self.frames))
|
||||
mob = Mobject(*[
|
||||
TexMobject(char).shift(0.3*x*RIGHT)
|
||||
for char, x, in zip(str(count), it.count())
|
||||
|
@ -480,14 +480,3 @@ class WithToes(Scene):
|
|||
|
||||
if __name__ == "__main__":
|
||||
command_line_create_scene(MOVIE_PREFIX)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2671,7 +2671,7 @@ class SmoothBritainLogLogPlot(IntroduceLogLogPlot):
|
|||
interim_point1 = p2[0]*RIGHT + p1[1]*UP
|
||||
interim_point2 = p4[0]*RIGHT + p3[1]*UP
|
||||
|
||||
print self.func(2)
|
||||
print(self.func(2))
|
||||
|
||||
slope_lines1, slope_lines2 = VMobject(), VMobject()
|
||||
slope_lines1.set_points_as_corners(
|
||||
|
@ -2956,19 +2956,3 @@ class Thumbnail(Scene):
|
|||
koch_curve.to_edge(DOWN, buff = SMALL_BUFF)
|
||||
|
||||
self.add(koch_curve, title)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ class BufferedCounting(SceneFromVideo):
|
|||
for dim, spread in zip(self.shape, spreads)
|
||||
]
|
||||
for frame, index in zip(self.frames, it.count()):
|
||||
print index, "of", len(self.frames)
|
||||
print(index + "of" + len(self.frames))
|
||||
blurred = cv2.GaussianBlur(frame, ksize, sigmaX)
|
||||
edged = cv2.Canny(blurred, threshold1, threshold2)
|
||||
buffed = reduce(np.dot, [matrices[0], edged, matrices[1]])
|
||||
|
@ -186,7 +186,7 @@ class ShowCounting(SceneFromVideo):
|
|||
SceneFromVideo.construct(self, path)
|
||||
total_time = len(self.frames)*self.frame_duration
|
||||
for count in range(32):
|
||||
print count
|
||||
print(count)
|
||||
mob = TexMobject(str(count)).scale(1.5)
|
||||
mob.shift(0.3*LEFT).to_edge(UP, buff = 0.1)
|
||||
index_range = range(
|
||||
|
@ -210,7 +210,7 @@ class ShowFrameNum(SceneFromVideo):
|
|||
path = os.path.join(MOVIE_DIR, MOVIE_PREFIX, filename+".mp4")
|
||||
SceneFromVideo.construct(self, path)
|
||||
for frame, count in zip(self.frames, it.count()):
|
||||
print count, "of", len(self.frames)
|
||||
print(count + "of" + len(self.frames))
|
||||
mob = Mobject(*[
|
||||
TexMobject(char).shift(0.3*x*RIGHT)
|
||||
for char, x, in zip(str(count), it.count())
|
||||
|
|
|
@ -158,11 +158,11 @@ class TestZetaOnHalfPlane(ZetaTransformationScene):
|
|||
self.add_transformable_plane()
|
||||
self.add_extra_plane_lines_for_zeta()
|
||||
self.prepare_for_transformation(self.plane)
|
||||
print sum([
|
||||
print(sum([
|
||||
mob.get_num_points()
|
||||
for mob in self.plane.family_members_with_points()
|
||||
])
|
||||
print len(self.plane.family_members_with_points())
|
||||
]))
|
||||
print(len(self.plane.family_members_with_points()))
|
||||
self.apply_zeta_function()
|
||||
self.dither()
|
||||
|
||||
|
@ -3359,8 +3359,3 @@ class ZetaPartialSums(ZetaTransformationScene):
|
|||
Transform(symbol, sigma)
|
||||
)
|
||||
self.dither()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ class Scene(object):
|
|||
name = str(self)
|
||||
file_path = self.get_movie_file_path(name, ".mp4")
|
||||
temp_file_path = file_path.replace(".mp4", "Temp.mp4")
|
||||
print "Writing to %s"%temp_file_path
|
||||
print("Writing to %s"%temp_file_path)
|
||||
self.args_to_rename_file = (temp_file_path, file_path)
|
||||
|
||||
fps = int(1/self.frame_duration)
|
||||
|
@ -502,29 +502,3 @@ class Scene(object):
|
|||
shutil.move(*self.args_to_rename_file)
|
||||
else:
|
||||
os.rename(*self.args_to_rename_file)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class SceneFromVideo(Scene):
|
|||
start_frame, end_frame = map(lambda t : fps*t, time_range)
|
||||
|
||||
frame_count = end_frame - start_frame
|
||||
print "Reading in " + file_name + "..."
|
||||
print("Reading in " + file_name + "...")
|
||||
for count in show_progress(range(start_frame, end_frame+1)):
|
||||
returned, frame = cap.read()
|
||||
if not returned
|
||||
|
@ -52,6 +52,3 @@ class SceneFromVideo(Scene):
|
|||
for index in range(len(self.frames)):
|
||||
for i in range(3):
|
||||
self.frames[index][:,:,i] = edged_frames[index]
|
||||
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue