Finalize vector.py
This commit is contained in:
@@ -114,9 +114,9 @@ class Matrix:
|
||||
if isinstance(other, Matrix):
|
||||
if self.__shape__ != other.__shape__:
|
||||
raise ValueError("The shape of the operands must be the same")
|
||||
return self.__data__ + other.__data__
|
||||
return Matrix(self.__data__ + other.__data__)
|
||||
elif isinstance(other, int) or isinstance(other, float):
|
||||
return self.__data__ + other
|
||||
return Matrix(self.__data__ + other)
|
||||
else:
|
||||
raise ValueError("Only a number or another ``Matrix`` can be added to a ``Matrix``")
|
||||
|
||||
@@ -145,7 +145,7 @@ class Matrix:
|
||||
|
||||
def __truediv__(self, other):
|
||||
if isinstance(other, int) or isinstance(other, float):
|
||||
return self.__data__ / other
|
||||
return Matrix(self.__data__ / other)
|
||||
else:
|
||||
raise ValueError("A ``Matrix`` can only be divided ba a number")
|
||||
|
||||
@@ -172,4 +172,3 @@ class Matrix:
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.__data__[key] = value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user