Simplifying jupyter notebook flags #2783
Replies: 4 comments
-
I think the cell contents is passed in as a string to manim/manim/utils/ipython_magic.py Line 34 in 4716331 So I think you'd only need to add the check to that, and change manim/manim/utils/ipython_magic.py Line 81 in 4716331 |
Beta Was this translation helpful? Give feedback.
-
Nice!
|
Beta Was this translation helpful? Give feedback.
-
ok, here is now the implementation: string="""
class Pendulum1(ZoomedScene):
def construct(self):
pendulum = Pendulum(weight=1, amplitude=12, acceleration=10, length=3, time=0)
self.add(pendulum)
#class Pendulum2(Scene):
# def construct(self):
# pendulum = Pendulum(weight=1, amplitude=12, acceleration=10, length=3, time=0)
# self.add(pendulum)
""" scenes= []
for li in string.splitlines():
if not li.startswith("#"):
result = re.search(r'class(.*?)\((SceneGraph|Scene|ThreeDScene|ZoomedScene|MovingCameraScene|ZoomedScene)', li)
if result != None:
scenes.append(result.group(1))
print(scenes[0])
|
Beta Was this translation helpful? Give feedback.
-
I've already mentioned this in private communications, but I'd like to have this on the issue as well: I don't like the approach where string parsing is used to detect the class name. I'd much rather use the existing logic from |
Beta Was this translation helpful? Give feedback.
-
Currently, a cell looks like this:
but as jupyter cells most likely will not contain more than one manim Scene, it would be really convenient to not mention the scene in the cell magic, e.g. like this:
My first idea would be to search the cell with a regular expression to search for
class XX(Scene)
and fetching XX as the scene name that needs to be rendered.
However, I did not find a way yet to grab the text of the current jupyter cell, and this seems to be a very hacky solution. Any other ideas? cc @behackl
Beta Was this translation helpful? Give feedback.
All reactions