mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Replace legacy numpy usage ruff rule NPY002 (#4516)
This commit is contained in:
parent
4bc77b3a00
commit
dc4a8bb741
6 changed files with 10 additions and 6 deletions
|
|
@ -791,13 +791,13 @@ class StreamLines(VectorField):
|
|||
self.stroke_width = stroke_width
|
||||
|
||||
half_noise = self.noise_factor / 2
|
||||
np.random.seed(0)
|
||||
rng = np.random.default_rng(0)
|
||||
start_points = np.array(
|
||||
[
|
||||
(x - half_noise) * RIGHT
|
||||
+ (y - half_noise) * UP
|
||||
+ (z - half_noise) * OUT
|
||||
+ self.noise_factor * np.random.random(3)
|
||||
+ self.noise_factor * rng.random(3)
|
||||
for n in range(self.n_repeats)
|
||||
for x in np.arange(*self.x_range)
|
||||
for y in np.arange(*self.y_range)
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ class Scene:
|
|||
self.foreground_mobjects: list[Mobject] = []
|
||||
if self.random_seed is not None:
|
||||
random.seed(self.random_seed)
|
||||
np.random.seed(self.random_seed)
|
||||
np.random.default_rng(self.random_seed)
|
||||
|
||||
@property
|
||||
def camera(self) -> Camera | OpenGLCamera:
|
||||
|
|
|
|||
|
|
@ -114,8 +114,9 @@ class QuickHull:
|
|||
|
||||
def initialize(self, points: PointND_Array) -> None:
|
||||
# Sample Points
|
||||
rng = np.random.default_rng()
|
||||
simplex = points[
|
||||
np.random.choice(points.shape[0], points.shape[1] + 1, replace=False)
|
||||
rng.choice(points.shape[0], points.shape[1] + 1, replace=False)
|
||||
]
|
||||
self.unclaimed = points
|
||||
new_internal: PointND = np.mean(simplex, axis=0)
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ select = [
|
|||
"E",
|
||||
"F",
|
||||
"I",
|
||||
"NPY",
|
||||
"PERF",
|
||||
"PGH",
|
||||
"PT",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ from manim import ImageMobject
|
|||
|
||||
@pytest.mark.parametrize("dtype", [np.uint8, np.uint16])
|
||||
def test_invert_image(dtype):
|
||||
array = (255 * np.random.rand(10, 10, 4)).astype(dtype)
|
||||
rng = np.random.default_rng()
|
||||
array = (255 * rng.random((10, 10, 4))).astype(dtype)
|
||||
image = ImageMobject(array, pixel_array_dtype=dtype, invert=True)
|
||||
assert image.pixel_array.dtype == dtype
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ def test_angle_of_vector():
|
|||
|
||||
|
||||
def test_angle_of_vector_vectorized():
|
||||
vec = np.random.randn(4, 10)
|
||||
rng = np.random.default_rng()
|
||||
vec = rng.standard_normal((4, 10))
|
||||
ref = [np.angle(complex(*v[:2])) for v in vec.T]
|
||||
np.testing.assert_array_equal(ref, angle_of_vector(vec))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue