-
Notifications
You must be signed in to change notification settings - Fork 2.5k
add api docs & examples for number_line module #1064
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
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.
Thanks for the contribution! Wonderful example image illustrating the usage!
Co-authored-by: Jason Villanueva <[email protected]>
Co-authored-by: Jason Villanueva <[email protected]>
tick_frequency=1, | ||
color: Colors = LIGHT_GREY, | ||
unit_size: int = 1, | ||
width: float = None, |
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.
use typing.Optional
x_max=config["frame_x_radius"], | ||
numbers_with_elongated_ticks: typing.List[float] = [0], | ||
include_numbers: bool = False, | ||
numbers_to_show: typing.List[float] = None, |
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.
use typing.Optional
tip_height: float = 0.25, | ||
add_start: float = 0, # extend number line by this amount at its starting point | ||
add_end: float = 0, # extend number line by this amount at its end point | ||
decimal_number_config: dict = {"num_decimal_places": 0}, |
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.
decimal_number_config: dict = {"num_decimal_places": 0}, | |
decimal_number_config: typing.Dict[str,int] = {"num_decimal_places": 0}, |
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.
actually, it is not appropriate in this context because decimal_number_config is essentially the kwargs for DecimalNumber class and the values for the dictionary entries passed could other types.
Maybe Any
instead of int
is appropriate.
That said, I think this is too confusing and somewhere stems from the overuse of passing 'dictionaries' in manim.
The correct way should be to define a dataclass and then pass it around. ... nevertheless whatever we do writing scalable and maintainable code in python is always going to be tricky in this project or any other project.
Given all this ambiguity, my humble suggestion is to leave it at dict
, and when (and if) you refactor the manim code to use proper types (instead of dictionaries) then the types would help otherwise this does not bring any value.
x_min: float = -config["frame_x_radius"], | ||
x_max: float = config["frame_x_radius"], | ||
**kwargs | ||
): |
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.
): | |
) -> None: |
self.tick_frequency, np.ceil(self.x_min / self.tick_frequency) | ||
) | ||
|
||
def add_tick_marks(self): |
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.
def add_tick_marks(self): | |
def add_tick_marks(self) -> None: |
) | ||
|
||
def get_tick(self, x, size=None): | ||
def get_tick(self, x: float, size: float = None) -> Line: |
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.
def get_tick(self, x: float, size: float = None) -> Line: | |
def get_tick(self, x: float, size: typing.Optional[float] = None) -> Line: |
number_config: dict = None, | ||
scale_val: float = None, | ||
direction: np.ndarray = None, | ||
buff: float = None, |
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.
number_config: dict = None, | |
scale_val: float = None, | |
direction: np.ndarray = None, | |
buff: float = None, | |
number_config: typing.Optional[dict] = None, | |
scale_val: typing.Optional[float] = None, | |
direction: typing.Optional[np.ndarray] = None, | |
buff: typing.Optional[float] = None, |
tick_frequency: float = 0.1, | ||
numbers_with_elongated_ticks: typing.List[float] = [0, 1], | ||
number_at_center: float = 0.5, | ||
decimal_number_config: dict = { |
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.
decimal_number_config: dict = { | |
decimal_number_config: typing.Dict[sstr,int] = { |
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 u have a typo here and I am not sure it is correct typing annotation in the first place. See above comment.
@naveen521kk I do not see the value in adding Optional typing where the None is specified (as it is obvious that argument is optional). I think it is overkill to do so and comes in the way of readability. I am not going to add the typings that you are recommending for the reason mentioned above. That said, I do respect the conventions and policies of a given project so if you want to archive/delete this pull request I am okay with it. Or if you want to merge it as it is and then do the necessary modifications as a follow-up as you see fit. Thanks |
Motivation
Adding the documentation & examples for number_line module
Overview / Explanation for Changes
Oneline Summary of Changes
Testing Status
Locally verified the generated document
Further Comments
Have not documented
init_leftmost_tick
as it should be considered a private methodAcknowledgements
Reviewer Checklist