Remove usage of np.append

This commit is contained in:
Grant Sanderson
2020-02-13 12:03:54 -08:00
parent c780a7471b
commit c654ca4506
5 changed files with 8 additions and 11 deletions

View File

@ -653,7 +653,7 @@ class Vector(Arrow):
def __init__(self, direction=RIGHT, **kwargs):
if len(direction) == 2:
direction = np.append(np.array(direction), 0)
direction = np.hstack([direction, 0])
Arrow.__init__(self, ORIGIN, direction, **kwargs)

View File

@ -346,10 +346,7 @@ class Mobject(Container):
This can make transition animations nicer
"""
def repeat_array(array):
return reduce(
lambda a1, a2: np.append(a1, a2, axis=0),
[array] * count
)
return np.vstack([array] * count)
for mob in self.family_members_with_points():
mob.apply_over_attr_arrays(repeat_array)
return self

View File

@ -27,7 +27,7 @@ class PMobject(Mobject):
if not isinstance(points, np.ndarray):
points = np.array(points)
num_new_points = len(points)
self.points = np.append(self.points, points, axis=0)
self.points = np.vstack([self.points, points])
if rgbas is None:
color = Color(color) if color else self.color
rgbas = np.repeat(
@ -37,7 +37,7 @@ class PMobject(Mobject):
)
elif len(rgbas) != len(points):
raise Exception("points and rgbas must have same shape")
self.rgbas = np.append(self.rgbas, rgbas, axis=0)
self.rgbas = np.vstack([self.rgbas, rgbas])
return self
def set_color(self, color=YELLOW_C, family=True):