Skip to content

Add ArcPolygon to geometry.py #707

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
Nov 22, 2020
Merged

Add ArcPolygon to geometry.py #707

merged 43 commits into from
Nov 22, 2020

Conversation

XorUnison
Copy link
Collaborator

Partial implementation of #210

Added ArcPolygon, to geometry.py

For test code and a result gif of the added feature, see #210, Test2.

@XorUnison
Copy link
Collaborator Author

So I attempted to put this after the first rendered example to demonstrate how to access the arcs:

    >>> print(reuleaux_triangle.arcs)
    '[ArcBetweenPoints, ArcBetweenPoints, ArcBetweenPoints]'

For some reason it actually renders fine in the docs, I think. Now for some inconceivable reason the other installation tests try to run this code... I'm open to suggestions on how to rewrite that part.

@leotrs
Copy link
Contributor

leotrs commented Nov 14, 2020

Sorry I don't understand what you are asking 🤔

@XorUnison
Copy link
Collaborator Author

Sorry I don't understand what you are asking 🤔

I'm talking about this error message from the 9 CI tests:

925     >>> print(reuleaux_triangle.arcs)
UNEXPECTED EXCEPTION: NameError("name 'reuleaux_triangle' is not defined",)

Something about the doctest failing, despite the docs rendering fine. Clearly some part of the code gets it into it's head to try computing the part behind the >>>, which inevitably fails. I'll be looking into this tomorrow myself unless someone has a good suggestion in th meantime.

@behackl
Copy link
Member

behackl commented Nov 14, 2020

This is a feature: when using Python code and also specifying the expected output, then the corresponding lines are actually tested and checked within our pipeline.

The manim directive can handle this situation, but you will need to write the test a little bit differently: currently, your reuleaux_triangle is only accessible within the construct method of your class, it could not be accessed outside of it anyways. My suggestion would be to write it as follows:

.. manim:: ArcPolygonExample

    >>> arc_conf = {"stroke_width":0}
    >>> poly_conf = {"stroke_width":10,"stroke_color":BLUE,
    ...     "fill_opacity":1,"color": PURPLE}
    >>> a = [-1,0,0]
    >>> b = [1,0,0]
    >>> c = [0,np.sqrt(3),0]
    >>> arc0 = ArcBetweenPoints(a, b, radius=2, **arc_conf)
    >>> arc1 = ArcBetweenPoints(b, c, radius=2, **arc_conf)
    >>> arc2 = ArcBetweenPoints(c, a, radius=2, **arc_conf)
    >>> reuleaux_tri = ArcPolygon(arc0, arc1, arc2, **poly_conf)
    >>> reuleaux_tri.arcs
    [ArcBetweenPoints, ArcBetweenPoints, ArcBetweenPoints]
    >>> class ArcPolygonExample(Scene):
    ...     def construct(self):
    ...         self.play(FadeIn(reuleaux_tri))
    ...         self.wait(2)

The indentation of your manim-block is currently also messed up, the .. manim:: needs to start on the same level as the text before.

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you efforts! The code looks good in general to me -- however, I do have an issue with the current user interface.

XorUnison and others added 2 commits November 17, 2020 14:12
Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
@kolibril13 kolibril13 added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Nov 18, 2020
@XorUnison
Copy link
Collaborator Author

I think this is about ready to get merged now, the docs build halfway decent and are very detailed, the 2 classes work nice too.
The docstrings will have to be edited again though once the Attributes issue is fixed.

Copy link
Contributor

@leotrs leotrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only requesting minor stuff. Thanks for all the work.

Copy link
Member

@behackl behackl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added two commits (aa75e13, 3ab3555) with some minor changes in the formatting of the documentation; I am satisfied otherwise. Let me know if you are okay with this too, @XorUnison, then I'll merge it. (Or actually, I'll approve it now; if you are satisfied you can also just merge yourself.)

@XorUnison
Copy link
Collaborator Author

XorUnison commented Nov 22, 2020

I've added two commits (aa75e13, 3ab3555)

Looks good to me so I'll go ahead and merge.

@XorUnison XorUnison merged commit 3c347d7 into ManimCommunity:master Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants