Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions linear_algebra/src/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __sub__(self, other):
size = len(self)
if size == len(other):
result = [self.__components[i] - other.component(i) for i in range(size)]
return result
return Vector(result)
else: # error case
raise Exception("must have the same size")

Expand All @@ -130,7 +130,7 @@ def __mul__(self, other):
"""
if isinstance(other, float) or isinstance(other, int):
ans = [c * other for c in self.__components]
return ans
return Vector(ans)
elif isinstance(other, Vector) and (len(self) == len(other)):
size = len(self)
summe = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_euclidLength(self):
test for the eulidean length
"""
x = Vector([1, 2])
self.assertAlmostEqual(x.eulidLength(), 2.236, 3)
self.assertAlmostEqual(x.euclidLength(), 2.236, 3)

def test_add(self):
"""
Expand Down Expand Up @@ -156,13 +156,6 @@ def test_squareZeroMatrix(self):
str(squareZeroMatrix(5)),
)

def force_test() -> None:
"""
This will ensure that pytest runs the unit tests above.
To explore https://github.com/TheAlgorithms/Python/pull/1124 uncomment the line below.
>>> # unittest.main()
"""
pass


if __name__ == "__main__":
unittest.main()