ManimCommunity / ManimCommunity/manim

StreamLines sets seed for np.random but not for random

Open
#2,402 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

Enhancement proposal

The streamlines are always rendered. The cached version is never used. The reason is that the code for StreamLines sets np.random.seed(0), the seed for np.random. However, another radomizer is actualy used. I have several sugestions:

  • set the radomizer random.seed() as well, or
  • use only the radomizer from numpy to generate streamlines, or
  • mention the necessity to set the randomizer in documentation.

Additional comments

The following code is from example on manim webpage. Adding the second and third lines speeds up the second and other compilations by a large factor.

from manim import *
import random
random.seed(10)


class ContinuousMotion(Scene):
    def construct(self):
        func = lambda pos: np.sin(pos[0] / 2) * UR + np.cos(pos[1] / 2) * LEFT
        stream_lines = StreamLines(func, stroke_width=2, max_anchors_per_line=30)
        self.add(stream_lines)
        stream_lines.start_animation(warm_up=False, flow_speed=1.5)
        self.wait(stream_lines.virtual_time / stream_lines.flow_speed)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the StreamLines implementation and the np.random.seed(0) call. Trace which randomizer generates the streamlines and how caching depends on deterministic output. Done means the selected seeding approach makes subsequent renders use the cached version, or the documentation clearly explains the required randomizer setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.