Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Small fixes to matrix.py

Grant Sanderson81790cb847b7
diff --git a/mobject/matrix.py b/mobject/matrix.py
index cb8e1af2c..7558cf771 100644
--- a/mobject/matrix.py
+++ b/mobject/matrix.py
@@ -72,9 +72,7 @@ class Matrix(VMobject):
or mobjects
"""
VMobject.__init__(self, **kwargs)
- matrix = np.array(matrix)
- if matrix.ndim == 1:
- matrix = matrix.reshape((matrix.size, 1))
+ matrix = np.array(matrix, ndmin=1)
mob_matrix = self.matrix_to_mob_matrix(matrix)
self.organize_mob_matrix(mob_matrix)
self.elements = VGroup(*mob_matrix.flatten())
@@ -89,11 +87,9 @@ class Matrix(VMobject):
self.add_background_rectangle()
def matrix_to_mob_matrix(self, matrix):
- return np.vectorize(
- lambda e: self.element_to_mobject(
- e, **self.element_to_mobject_config
- )
- )(matrix)
+ return np.vectorize(self.element_to_mobject)(
+ matrix
+ )
def organize_mob_matrix(self, matrix):
for i, row in enumerate(matrix):