Skip to content

Commit 89ec770

Browse files
codecalecstokhos
authored andcommitted
Fixes in methods and tests in Linear Algebra (TheAlgorithms#1432)
* Fixes in methods and tests * Renamed tests.py to test_linear_algebra.py * removed force_test() * Delete test_linear_algebra.py * Format code with psf/black * Rename tests.py to test_linear_algebra.py
1 parent 4f9b336 commit 89ec770

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

linear_algebra/src/lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __sub__(self, other):
119119
size = len(self)
120120
if size == len(other):
121121
result = [self.__components[i] - other.component(i) for i in range(size)]
122-
return result
122+
return Vector(result)
123123
else: # error case
124124
raise Exception("must have the same size")
125125

@@ -130,7 +130,7 @@ def __mul__(self, other):
130130
"""
131131
if isinstance(other, float) or isinstance(other, int):
132132
ans = [c * other for c in self.__components]
133-
return ans
133+
return Vector(ans)
134134
elif isinstance(other, Vector) and (len(self) == len(other)):
135135
size = len(self)
136136
summe = 0

linear_algebra/src/tests.py renamed to linear_algebra/src/test_linear_algebra.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_euclidLength(self):
4545
test for the eulidean length
4646
"""
4747
x = Vector([1, 2])
48-
self.assertAlmostEqual(x.eulidLength(), 2.236, 3)
48+
self.assertAlmostEqual(x.euclidLength(), 2.236, 3)
4949

5050
def test_add(self):
5151
"""
@@ -156,13 +156,6 @@ def test_squareZeroMatrix(self):
156156
str(squareZeroMatrix(5)),
157157
)
158158

159-
def force_test() -> None:
160-
"""
161-
This will ensure that pytest runs the unit tests above.
162-
To explore https://github.com/TheAlgorithms/Python/pull/1124 uncomment the line below.
163-
>>> # unittest.main()
164-
"""
165-
pass
166-
159+
167160
if __name__ == "__main__":
168161
unittest.main()

0 commit comments

Comments
 (0)