ManimCommunity / ManimCommunity/manim
StreamLines sets seed for np.random but not for random
Nobody has claimed this yet.
- 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
numpyto 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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