Skip to content
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

double negative sign error #4094

Closed
Fgkl10 opened this issue Jan 8, 2025 · 2 comments
Closed

double negative sign error #4094

Fgkl10 opened this issue Jan 8, 2025 · 2 comments

Comments

@Fgkl10
Copy link

Fgkl10 commented Jan 8, 2025

Description of bug / unexpected behavior

it report a mistake

Expected behavior

i want to two nagetive sign become a positive sign
but it report mistake!!

How to reproduce the issue

Code for reproducing the problem
from manim import *
class sin(Scene):
    def construct(self):
        axes = Axes(
                    x_range=[-PI*(-2), PI*2],  # x轴从 -π/2 到 π/2
                    y_range=[-1.5, 1.5],     # y轴从 -1.5 到 1.5
                    axis_config={"color": WHITE},
                )
        graph = axes.plot(lambda x: np.cos(x), color=BLUE)
        self.play(Create(axes), Create(graph))

Additional media files

Images/GIFs

Logs

Terminal output
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ D:\python\math_animation\venv\Lib\site-packages\manim\cli\render\commands.py:120 in render       │
│                                                                                                  │
│   117 │   │   │   try:                                                                           │
│   118 │   │   │   │   with tempconfig({}):                                                       │
│   119 │   │   │   │   │   scene = SceneClass()                                                   │
│ ❱ 120 │   │   │   │   │   scene.render()                                                         │
│   121 │   │   │   except Exception:                                                              │
│   122 │   │   │   │   error_console.print_exception()                                            │
│   123 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\scene\scene.py:229 in render               │
│                                                                                                  │
│    226 │   │   """                                                                               │
│    227 │   │   self.setup()                                                                      │
│    228 │   │   try:                                                                              │
│ ❱  229 │   │   │   self.construct()                                                              │
│    230 │   │   except EndSceneEarlyException:                                                    │
│    231 │   │   │   pass                                                                          │
│    232 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ D:\python\math_animation\bug.py:4 in construct                                                   │
│                                                                                                  │
│    1 from manim import *                                                                         │
│    2 class sin(Scene):                                                                           │
│    3 │   def construct(self):                                                                    │
│ ❱  4 │   │   axes = Axes(                                                                        │
│    5 │   │   │   │   │   x_range=[-PI*(-2), PI*2],  # x轴从 -π/2 到 π/2                          │
│    6 │   │   │   │   │   y_range=[-1.5, 1.5],     # y轴从 -1.5 到 1.5                            │
│    7 │   │   │   │   │   axis_config={"color": WHITE},                                           │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\graphing\coordinate_systems.py:189 │
│ 6 in __init__                                                                                    │
│                                                                                                  │
│   1893 │   │   else:                                                                             │
│   1894 │   │   │   self.y_axis_config["exclude_origin_tick"] = False                             │
│   1895 │   │                                                                                     │
│ ❱ 1896 │   │   self.x_axis = self._create_axis(self.x_range, self.x_axis_config, self.x_length)  │
│   1897 │   │   self.y_axis = self._create_axis(self.y_range, self.y_axis_config, self.y_length)  │
│   1898 │   │                                                                                     │
│   1899 │   │   # Add as a separate group in case various other                                   │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\graphing\coordinate_systems.py:197 │
│ 1 in _create_axis                                                                                │
│                                                                                                  │
│   1968 │   │   │   Returns a number line based on ``range_terms``.                               │
│   1969 │   │   """                                                                               │
│   1970 │   │   axis_config["length"] = length                                                    │
│ ❱ 1971 │   │   axis = NumberLine(range_terms, **axis_config)                                     │
│   1972 │   │                                                                                     │
│   1973 │   │   # without the call to _origin_shift, graph does not exist when min > 0 or max <   │
│   1974 │   │   # shifts the axis so that 0 is centered                                           │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\graphing\number_line.py:231 in     │
│ __init__                                                                                         │
│                                                                                                  │
│   228 │   │   self.center()                                                                      │
│   229 │   │                                                                                      │
│   230 │   │   if self.include_tip:                                                               │
│ ❱ 231 │   │   │   self.add_tip(                                                                  │
│   232 │   │   │   │   tip_length=self.tip_height,                                                │
│   233 │   │   │   │   tip_width=self.tip_width,                                                  │
│   234 │   │   │   │   tip_shape=tip_shape,                                                       │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\geometry\arc.py:121 in add_tip     │
│                                                                                                  │
│    118 │   │   │   tip = self.create_tip(tip_shape, tip_length, tip_width, at_start)             │
│    119 │   │   else:                                                                             │
│    120 │   │   │   self.position_tip(tip, at_start)                                              │
│ ❱  121 │   │   self.reset_endpoints_based_on_tip(tip, at_start)                                  │
│    122 │   │   self.asign_tip_attr(tip, at_start)                                                │
│    123 │   │   self.add(tip)                                                                     │
│    124 │   │   return self                                                                       │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\geometry\arc.py:204 in             │
│ reset_endpoints_based_on_tip                                                                     │
│                                                                                                  │
│    201 │   │   if at_start:                                                                      │
│    202 │   │   │   self.put_start_and_end_on(tip.base, self.get_end())                           │
│    203 │   │   else:                                                                             │
│ ❱  204 │   │   │   self.put_start_and_end_on(self.get_start(), tip.base)                         │
│    205 │   │   return self                                                                       │
│    206 │                                                                                         │
│    207 │   def asign_tip_attr(self, tip: tips.ArrowTip, at_start: bool) -> Self:                 │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\geometry\tips.py:133 in base       │
│                                                                                                  │
│   130 │   │   │   array([1.65, 0.  , 0.  ])                                                      │
│   131 │   │                                                                                      │
│   132 │   │   """                                                                                │
│ ❱ 133 │   │   return self.point_from_proportion(0.5)                                             │
│   134 │                                                                                          │
│   135 │   @property                                                                              │
│   136 │   def tip_point(self) -> Point3D:                                                        │
│                                                                                                  │
│ D:\python\math_animation\venv\Lib\site-packages\manim\mobject\types\vectorized_mobject.py:1451   │
│ in point_from_proportion                                                                         │
│                                                                                                  │
│   1448 │   │   │   │   return curve(residue)                                                     │
│   1449 │   │   │                                                                                 │
│   1450 │   │   │   current_length += length                                                      │
│ ❱ 1451 │   │   raise Exception(                                                                  │
│   1452 │   │   │   "Not sure how you reached here, please file a bug report at https://github.c  │
│   1453 │   │   )                                                                                 │
│   1454                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
Exception: Not sure how you reached here, please file a bug report at https://github.com/ManimCommunity/manim/issues/new/choose

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)):
  • RAM:
  • Python version (python/py/python3 --version):
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:

Additional comments

@CobaltIII
Copy link

I think it is becoming +2PI (-PI*(-2) = 2PI) as both the start and the end of the X-axis. The error is probably occuring because the start and end points become the same causing the length variable of the X-axis to be 0. Thus somehow causing a division by 0 error. I read the comment and it said that the range is supposed to go from -PI/2 to +PI/2, for that the appropriate line of code should probably be this.

axes = Axes( 
                    x_range=[-PI/(2), PI/2],  # x轴从 -π/2 到 π/2
                    y_range=[-1.5, 1.5],     # y轴从 -1.5 到 1.5
                    axis_config={"color": WHITE},
                )

This seems to be working on my system with the current codebase. Please tell me if I have misunderstood your issue.

@uwezi
Copy link
Contributor

uwezi commented Jan 8, 2025

I guess @CobaltIII is right here, your comment seems to indicate that you intend an x_range from -PI/2 to +PI/2 but you wrote -PI*(-2) which is equal to +2*PI and thus you get a zero-length x_range from +2*PI to +2*PI

image

I have no idea what you mean by "double negative sign error" though... For questions like this I recommend that you join the Discord server, rather than opening an issue on Github which is meant to reveal possible bugs in the Manim code base rather then misunderstandings.

from manim import *
class sin(Scene):
    def construct(self):
        axes = Axes(
                    x_range=[-PI/2, PI/2],  # x轴从 -π/2 到 π/2
                    y_range=[-1.5, 1.5],     # y轴从 -1.5 到 1.5
                    axis_config={"color": WHITE},
                ).add_coordinates()
        graph = axes.plot(lambda x: np.cos(x), color=BLUE)
        self.play(Create(axes), Create(graph))
        self.wait()
sin.mp4

@Fgkl10 Fgkl10 closed this as completed Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants