Skip to content

Fixes in methods and tests in Linear Algebra #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 2 additions & 9 deletions linear_algebra/src/tests.py
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()