Vector now returns an ndarray when multiplied with one.
This commit is contained in:
parent
5a1170b856
commit
8c02496a43
@ -100,6 +100,8 @@ class Vector(namedtuple("_Vector", ("x", "y", "z"))):
|
|||||||
def __mul__(self, other):
|
def __mul__(self, other):
|
||||||
if isinstance(other, (int, float)):
|
if isinstance(other, (int, float)):
|
||||||
return Vector(self[0] * other, self[1] * other, self[2] * other)
|
return Vector(self[0] * other, self[1] * other, self[2] * other)
|
||||||
|
elif isinstance(other, numpy.ndarray):
|
||||||
|
return other.__rmul__(self)
|
||||||
|
|
||||||
return Vector(self[0] * other[0], self[1] * other[1], self[2] * other[2])
|
return Vector(self[0] * other[0], self[1] * other[1], self[2] * other[2])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user