Skip to content

Implement a basic Subcommand structure. #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cbbfab1
Added subparser for extra commands.
Jul 22, 2020
17a777f
Renamed main to write.
Jul 22, 2020
744d0a1
Displayed all config files read, and not just the last.
Jul 22, 2020
0ac65f3
Removed manim-cfg command.
Jul 22, 2020
558502c
Fix a bug where only using `manim` as command would throw an error.
Jul 22, 2020
237ea01
Change what __all__ is.
Jul 22, 2020
457e151
Check for number of arguments in multiple places.
Jul 22, 2020
4a98e59
Change minimum arguments if called via python.
Jul 22, 2020
4938acb
Only use subparser if a non-rendering related command appears.
Jul 22, 2020
95dd479
Make subcommand system less hacky.
Jul 23, 2020
35add6f
Show cfg stuff in help commands as well.
Jul 23, 2020
2b6bc73
Made the export command check if inpath and outpath are same.
Jul 24, 2020
72afdbc
Added curr_config_dict to __all__
Jul 24, 2020
5d6d69b
Renamed cfg_file_utils.py to cfg_subcmd.py
Jul 24, 2020
9270932
Stopped yelling at end user ;)
Jul 24, 2020
64626de
Refactored detection of subcommands and resultant control flow.
Jul 24, 2020
7a64551
Added ability to modify all boolean config vars in cfg write.
Jul 25, 2020
f400d3d
Add newline at end to conform with formatting rules.
Jul 25, 2020
31e7479
Only Create Media Dir if not using subcommand.
Jul 26, 2020
1f3091c
Add condition to check if _run_config() is being called from manim/__…
Jul 26, 2020
cd42520
Add test for current cfg subcommands.
Jul 26, 2020
f9febea
Fix a relative import.
Jul 26, 2020
9686500
Change a deprecated warning method.
Jul 26, 2020
59d846c
Check if _run_config is called from manil/__main__.py
Jul 26, 2020
e885280
Properly change cwd and change back as required.
Jul 26, 2020
5c2bc1f
Add test for manim cfg write
Jul 27, 2020
8060eeb
Clarify use of write_cfg_sbcmd_input
Jul 27, 2020
1bf8aef
Use os.pardir instead of ".."
Aathish04 Jul 28, 2020
7f4a88d
Add cross-platform file opening method.
Jul 28, 2020
6ad0001
Add --open flag for cfg write
Jul 28, 2020
8d4ed87
Stop changing cwd from mulitple files
Jul 28, 2020
9018eaa
Change directory in subprocess instead of in test.
Aathish04 Jul 28, 2020
2244fa9
Pass over full error message on error.
Aathish04 Jul 29, 2020
0297f84
Raised an exception if OS is unknown.
Aathish04 Jul 29, 2020
0104b1d
Merge branch 'cfg-subcommand' of https://github.com/aathish04/manim i…
Aathish04 Jul 29, 2020
bc38eb9
Remove a stray `
Aathish04 Jul 29, 2020
b40bbe2
Change square brackets to parentheses.
Aathish04 Jul 29, 2020
396f2fa
Change manim.cfg to original using pytest fixtures.
Aathish04 Jul 29, 2020
dab66e5
Merge branch 'cfg-subcommand' of https://github.com/aathish04/manim i…
Aathish04 Jul 29, 2020
dc94827
Rename `reset_config` to `reset_cfg_file` for clarity.
Aathish04 Jul 29, 2020
114e676
Merge branch 'master' into cfg-subcommand
Aathish04 Jul 31, 2020
da73e60
Apply Black's formatting.
Aathish04 Jul 31, 2020
05fb37b
Merge branch 'master' into cfg-subcommand
Aathish04 Aug 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@

# -- Project information -----------------------------------------------------

project = 'Manim'
copyright = '2019, EulerTour'
author = 'EulerTour'
project = "Manim"
copyright = "2019, EulerTour"
author = "EulerTour"


# -- General configuration ---------------------------------------------------
master_doc = 'index'
master_doc = "index"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -45,9 +44,9 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['assets']
html_static_path = ["assets"]
112 changes: 63 additions & 49 deletions logo/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

NEW_BLUE = "#68a8e1"


class Thumbnail(GraphScene):
CONFIG = {
"y_max": 8,
Expand All @@ -13,13 +14,15 @@ def construct(self):

def show_function_graph(self):
self.setup_axes(animate=False)

def func(x):
return 0.1 * (x + 3-5) * (x - 3-5) * (x-5) + 5
return 0.1 * (x + 3 - 5) * (x - 3 - 5) * (x - 5) + 5

def rect(x):
return 2.775*(x-1.5)+3.862
recta = self.get_graph(rect,x_min=-1,x_max=5)
graph = self.get_graph(func,x_min=0.2,x_max=9)
return 2.775 * (x - 1.5) + 3.862

recta = self.get_graph(rect, x_min=-1, x_max=5)
graph = self.get_graph(func, x_min=0.2, x_max=9)
graph.set_color(NEW_BLUE)
input_tracker_p1 = ValueTracker(1.5)
input_tracker_p2 = ValueTracker(3.5)
Expand All @@ -37,29 +40,40 @@ def get_y_point(input_tracker):
return self.coords_to_point(0, get_y_value(input_tracker))

def get_graph_point(input_tracker):
return self.coords_to_point(get_x_value(input_tracker), get_y_value(input_tracker))
return self.coords_to_point(
get_x_value(input_tracker), get_y_value(input_tracker)
)

def get_v_line(input_tracker):
return DashedLine(get_x_point(input_tracker), get_graph_point(input_tracker), stroke_width=2)
return DashedLine(
get_x_point(input_tracker),
get_graph_point(input_tracker),
stroke_width=2,
)

def get_h_line(input_tracker):
return DashedLine(get_graph_point(input_tracker), get_y_point(input_tracker), stroke_width=2)
#
return DashedLine(
get_graph_point(input_tracker),
get_y_point(input_tracker),
stroke_width=2,
)

#
input_triangle_p1 = RegularPolygon(n=3, start_angle=TAU / 4)
output_triangle_p1 = RegularPolygon(n=3, start_angle=0)
for triangle in input_triangle_p1, output_triangle_p1:
triangle.set_fill(WHITE, 1)
triangle.set_stroke(width=0)
triangle.scale(0.1)
#
#
input_triangle_p2 = RegularPolygon(n=3, start_angle=TAU / 4)
output_triangle_p2 = RegularPolygon(n=3, start_angle=0)
for triangle in input_triangle_p2, output_triangle_p2:
triangle.set_fill(WHITE, 1)
triangle.set_stroke(width=0)
triangle.scale(0.1)
#

#
x_label_p1 = TexMobject("a")
output_label_p1 = TexMobject("f(a)")
x_label_p2 = TexMobject("b")
Expand All @@ -83,11 +97,8 @@ def get_h_line(input_tracker):
graph_dot_p1.move_to(get_graph_point(input_tracker_p1))
graph_dot_p2.move_to(get_graph_point(input_tracker_p2))


#
self.play(
ShowCreation(graph),
)
self.play(ShowCreation(graph),)
# Animacion del punto a
self.add_foreground_mobject(graph_dot_p1)
self.add_foreground_mobject(graph_dot_p2)
Expand All @@ -106,7 +117,7 @@ def get_h_line(input_tracker):
ShowCreation(h_line_p2),
Write(output_label_p2),
DrawBorderThenFill(output_triangle_p2),
run_time=0.5
run_time=0.5,
)
self.add(
input_triangle_p2,
Expand All @@ -119,58 +130,61 @@ def get_h_line(input_tracker):
)
###################
pendiente_recta = self.get_secant_slope_group(
1.9, recta, dx = 1.4,
df_label = None,
dx_label = None,
dx_line_color = PURPLE,
df_line_color= ORANGE,
)
1.9,
recta,
dx=1.4,
df_label=None,
dx_label=None,
dx_line_color=PURPLE,
df_line_color=ORANGE,
)
grupo_secante = self.get_secant_slope_group(
1.5, graph, dx = 2,
df_label = None,
dx_label = None,
dx_line_color = "#942357",
df_line_color= "#3f7d5c",
secant_line_color = RED,
1.5,
graph,
dx=2,
df_label=None,
dx_label=None,
dx_line_color="#942357",
df_line_color="#3f7d5c",
secant_line_color=RED,
)


self.add(
input_triangle_p2,
graph_dot_p2,
v_line_p2,
h_line_p2,
output_triangle_p2,
input_triangle_p2, graph_dot_p2, v_line_p2, h_line_p2, output_triangle_p2,
)
self.play(FadeIn(grupo_secante))

kwargs = {
"x_min" : 4,
"x_max" : 9,
"fill_opacity" : 0.75,
"stroke_width" : 0.25,
"x_min": 4,
"x_max": 9,
"fill_opacity": 0.75,
"stroke_width": 0.25,
}
self.graph=graph
iteraciones=6

self.graph = graph
iteraciones = 6

self.rect_list = self.get_riemann_rectangles_list(
graph, iteraciones,start_color=PURPLE,end_color=ORANGE, **kwargs
graph, iteraciones, start_color=PURPLE, end_color=ORANGE, **kwargs
)
flat_rects = self.get_riemann_rectangles(
self.get_graph(lambda x : 0), dx = 0.5,start_color=invert_color(PURPLE),end_color=invert_color(ORANGE),**kwargs
self.get_graph(lambda x: 0),
dx=0.5,
start_color=invert_color(PURPLE),
end_color=invert_color(ORANGE),
**kwargs
)
rects = self.rect_list[0]
self.transform_between_riemann_rects(
flat_rects, rects,
replace_mobject_with_target_in_scene = True,
run_time=0.9
flat_rects, rects, replace_mobject_with_target_in_scene=True, run_time=0.9
)

# adding manim
picture = Group(*self.mobjects)
picture.scale(0.6).to_edge(LEFT, buff=SMALL_BUFF)
manim = TextMobject("Manim").set_height(1.5) \
.next_to(picture, RIGHT) \
.shift(DOWN * 0.7)
manim = (
TextMobject("Manim")
.set_height(1.5)
.next_to(picture, RIGHT)
.shift(DOWN * 0.7)
)
self.add(manim)
51 changes: 33 additions & 18 deletions manim/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import importlib.util
import types

from .config import file_writer_config
from .config import file_writer_config, args
from .utils import cfg_subcmds
from .scene.scene import Scene
from .utils.sounds import play_error_sound
from .utils.sounds import play_finish_sound
Expand Down Expand Up @@ -156,23 +157,37 @@ def get_module(file_name):


def main():
module = get_module(file_writer_config["input_file"])
all_scene_classes = get_scene_classes_from_module(module)
scene_classes_to_render = get_scenes_to_render(all_scene_classes)
sound_on = file_writer_config["sound"]
for SceneClass in scene_classes_to_render:
try:
# By invoking, this renders the full scene
scene = SceneClass()
open_file_if_needed(scene.file_writer)
if sound_on:
play_finish_sound()
except Exception:
print("\n\n")
traceback.print_exc()
print("\n\n")
if sound_on:
play_error_sound()
if hasattr(args, "subcommands"):
if "cfg" in args.subcommands:
if args.cfg_subcommand is not None:
subcommand = args.cfg_subcommand
if subcommand == "write":
cfg_subcmds.write(args.level, args.open)
elif subcommand == "show":
cfg_subcmds.show()
elif subcommand == "export":
cfg_subcmds.export(args.dir)
else:
logger.error("No argument provided; Exiting...")

else:
module = get_module(file_writer_config["input_file"])
all_scene_classes = get_scene_classes_from_module(module)
scene_classes_to_render = get_scenes_to_render(all_scene_classes)
sound_on = file_writer_config["sound"]
for SceneClass in scene_classes_to_render:
try:
# By invoking, this renders the full scene
scene = SceneClass()
open_file_if_needed(scene.file_writer)
if sound_on:
play_finish_sound()
except Exception:
print("\n\n")
traceback.print_exc()
print("\n\n")
if sound_on:
play_error_sound()


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions manim/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ def _parse_config(config_parser, args):
args, config_parser, file_writer_config, successfully_read_files = _run_config()
if _from_command_line():
logger.info(
f"Read configuration files: {os.path.abspath(successfully_read_files[-1])}"
f"Read configuration files: {[os.path.abspath(cfgfile) for cfgfile in successfully_read_files]}"
)
_init_dirs(file_writer_config)
if not (hasattr(args, "subcommands")):
_init_dirs(file_writer_config)
config = _parse_config(config_parser, args)
camera_config = config
Loading