Skip to content

StreamLines sets seed for np.random but not for random #2402

@robert-marik

Description

@robert-marik

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAdditions and improvements in general

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions