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

Hash of plotted curve should be invalidated when function changes (even if it is wrapped) #3806

Open
makai410 opened this issue Jun 15, 2024 · 4 comments

Comments

@makai410
Copy link

Description of bug / unexpected behavior

Caches are used in some inproper situations. Like when I had changed a formula that need to be draw on axes, yet not directly changed the curve's arguments, just an independent function having been changed, manim use the caches.

Expected behavior

In that case, manim should reload the codes.

How to reproduce the issue

Code for reproducing the problem
class Prove(Scene):
    def construct(self):
        def f(x):
            return (3*x**2+53/x)
        axes = Axes(x_range=[-1, 8, 1], y_range=[-1, 10, 1], x_length=9, y_length=7)
        curve = axes.plot(lambda x: f(x),x_range=[1, 7], color=DEF_GREEN)
        self.play(
            Create(axes),
            Create(curve)
        )
        self.wait()

For example, just change the function f(x) to this:

        def f(x):
            return (6*x**2+53/x)

then render, manim will use the caches.

System specifications

System Details
  • OS: Windows 10 v2004
  • RAM: 32GB DDR4
  • Python version: 3.11.9
  • Installed modules:
click             8.1.7      
cloup             3.0.5      
colorama          0.4.6      
decorator         5.1.1      
ffmpeg            1.4        
glcontext         2.5.0      
isosurfaces       0.1.2      
manim             0.18.1     
ManimPango        0.5.0      
mapbox-earcut     1.0.1
markdown-it-py    3.0.0
mdurl             0.1.2
moderngl          5.10.0
moderngl-window   2.4.6
multipledispatch  1.0.0
networkx          3.3
numpy             1.26.4
pillow            10.3.0
pip               24.0
pycairo           1.26.0
pydub             0.25.1
pyglet            2.0.15
Pygments          2.18.0
pyrr              0.10.3
rich              13.7.1
scipy             1.13.1
screeninfo        0.8.1
setuptools        65.5.0
skia-pathops      0.8.0.post1
srt               3.5.3
svgelements       1.9.6
tqdm              4.66.4
typing_extensions 4.12.2
watchdog          4.0.1
@makai410
Copy link
Author

Welcome cooperation to tackle this :)

@behackl behackl changed the title CACHES USING STRATEGY SUCKS Hash of plotted curve should be invalidated when function changes (even if it is wrapped) Jun 15, 2024
@uwezi
Copy link
Contributor

uwezi commented Jun 16, 2024

I cannot reproduce your problem. I mean the function which you have in your code has not a single visible point within the axes of your scene, neither has your replacement function.

bild

bild

When I toggle between 6*x**2+53/x and 6*x**2+53/x in the following code on my system, caching enabled, Manim always constructs the correct plot.

class Prove(Scene):
    def construct(self):
        def f(x):
            return (6*x**2+53/x)
        axes = Axes(x_range=[-1, 8, 1], y_range=[35, 55, 1], x_length=9, y_length=7)
        curve = axes.plot(lambda x: f(x),x_range=[1, 7], color=GREEN)
        self.play(
            Create(axes),
            Create(curve)
        )
        self.wait()

@makai410
Copy link
Author

Sorry for that I simplified this function while writing this issue; its original formula was:

def f(x):
    return (3*x**2+53/x)/16

If you change it to:

def f(x):
    return (9*x**2+53/x)/16

you will see manim use caches in the log.

@uwezi
Copy link
Contributor

uwezi commented Jun 16, 2024

It still does not for me - rendered with "3" and manim -pql .\20240613_01.py Prove

bild

Prove.mp4

rendered with "9"

bild

Prove.mp4

The log-output also suggest that Manim uses some cached parts, but obviously not the function lot itself...

bild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants