question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VGroup and VDict must override __repr__ to display the mobjects contained

See original GitHub issue

Consider this example:

class Test(Scene):
    def construct(self):
        sq = Square()
        cir = Circle()
        grp = VGroup(sq, cir)
        print(grp) # --> Just prints: VGroup
        self.play(ShowCreation(grp))
        dct = VDict({'s' : sq, 'c' : cir}).next_to(grp, DOWN)
        print(dct) # --> Just prints: VDict
        self.play(ShowCreation(dct))

When there are a lot of mobjects in the VGroup or VDict, it sometimes helps to know what are those mobjects while debugging. Something like [Square, Circle] or even better the full hash name (IDK what it’s called) – manim.mobject....at 0x00.... Let me know how can this be best incorporated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
huguesdevimeuxcommented, Oct 1, 2020

I don’t know the proper name either lol, but the hex thing at the end is the id, I think. And I think the id in the repr can be sometimes useful, when one wants to check if two objects are different.

1reaction
behacklcommented, Oct 1, 2020

I would prefer implementing __repr__ over __str__ (see https://stackoverflow.com/questions/1436703/difference-between-str-and-repr), and would love to see more manim classes having proper __repr__ methods. (Note in particular: if __repr__ is defined and __str__ is not, str(object) will still work.)

For the container, I fully agree that its repr should print a list of its children. But for something concrete like Square I would find it useful to let Square(side_length=5) print something like 'Square with side length 5', or even 'Square with side length 5 and center (0., 0., 0.)'; the more explicit and defining the better. (For your PR it is fine to just take care of VGroup and VDict, improving their representation strings is definitely more important. 👍)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source code for manim.mobject.types.vectorized_mobject
Image import Image from manim.mobject.opengl.opengl_compatibility import ... and the display will gradient to this secondary color in the direction of ...
Read more >
manim/vectorized_mobject.py at main - GitHub
A community-maintained Python framework for creating mathematical animations. - manim/vectorized_mobject.py at main · ManimCommunity/manim.
Read more >
How to "perfectly" override a dict? - python - Stack Overflow
You can write an object that behaves like a dict quite easily with ABCs (Abstract Base Classes) from the collections.abc module.
Read more >
vocab.txt - Hugging Face
... ndarray ##pth ##uid missing report ##ugh cent hasattr org display ignore ... ##ake x1 ##cessary 24 redis ##let ##elta included overwrite ##head...
Read more >
Manim is an animation engine for explanatory math videos.
Rewrite of the SVG "path" interpretation code. Added multiple SVG unit tests in small hand-created SVG files; Added multiple SVG system tests ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found