-
Notifications
You must be signed in to change notification settings - Fork 2.2k
# New colour enums- Try2 #488
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
Conversation
This LGTM, except I would also add an import statements in manim/init.py. for example if you add |
I guess you mean in from manim import Scene, Dot
import manim.utils.color as C
class Hello(Scene):
def construct(self):
dot = Dot().set_color(C.DARK_BLUE)
self.add(dot)
self.wait(1) But not Next step would be then, to go through all files and change the imports in a way, that only the colors needed are imported, like here https://github.com/ManimCommunity/manim/pull/342/files |
And just saw that random_color() also has to be rewritten |
@@ -65,6 +65,7 @@ | |||
|
|||
from .utils.bezier import * | |||
from .utils.color import * | |||
from .utils import color as color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line does not have an effect right now.
import manim.color as C
is not working, only
import manim.utils.color as C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try from manim import color as C
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nice, this one is working
from manim import Scene,Dot
from manim import color as C
class Foo(Scene):
def construct(self):
dot = Dot().set_color(C.GREEN)
self.add(dot)
self.wait(1)
@kolibril13 you seen to have run black on the whole codebase, as your PR now contains 58 files modified, including some that have nothing to do with colors. Can you please run black on only the files you have modified? |
Ok, now I reverted all the commits and ran black only on colors.py. |
Thank you! And I agree, right now it's fine. |
@@ -55,6 +55,7 @@ | |||
from ...utils.space_ops import angle_of_vector | |||
from ...utils.space_ops import complex_to_R3 | |||
from ...utils.space_ops import rotate_vector | |||
from ...utils.color import YELLOW, WHITE, DARK_GREY, MAROON_B, PURPLE, GREEN, BLACK, LIGHT_GREY, GREY, BLUE_B, BLUE_D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just import C? And use C.WHITE, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also possible.
But I wanted to keep it consistent with the others, so I chose this way
Another option would be to say in this example from ...utils.color import *
Almost there :) |
Oh real quick: I think there is a
@behackl Actually, could this be done through doctests? |
Also, can you please edit the changelog? Remember to add the fact that the colors have moved to an enum, as well as the fact that the user now has to set the random seed. Thanks :) |
Sure, just put something like
|
Co-authored-by: Leo Torres <leo@leotrs.com>
As this was also the case before, I think we don't have to add this to the changelog.
I scanned manimcm for this file. And there is nothing like test_import. |
I'm pretty sure this is a difference with respect to 3b1b.
Woops, I must have been thinking about a new branch I have. Can you please add |
I only added to the changelog "Added Colors have moved to an Enum". |
Ok, drop it. |
.. code-block:: python | ||
import manim.utils.color as C | ||
C.WHITE # -> '#FFFFFF' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little late to this party, but whatever, just as a general FYI: if this would have been written as
.. code-block:: python
>>> import manim.utils.color as C
>>> C.WHITE
'#FFFFFF'
then it would be a doctest, and these two lines would have been tested with every run of the pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kolibril13 let's do this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#496 ;)
Btw. does this mean, that the test can be removed?
All in all, I think we will have some redundancy when we have tests in the test folder and tests in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rule of thumb for tests is: if it is easy to setup and maybe even illustrates something useful for users, then it can be a doctest.
Stuff that needs more setup is certainly better suited in dedicated test files. :-)
This is very similar to #342,
but with an approach like this:
Where you get auto-completion and colours can be imported separately with
from manim.utils.color import DARK_BLUE
can be tested with:
In case that this PR looks reasonable, further things to do are: