Fixes in methods and tests in Linear Algebra (#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
This commit is contained in:
Alex Veltman 2019-10-24 12:39:51 +02:00 committed by Christian Clauss
parent 07483139d1
commit ec85cc8191
2 changed files with 4 additions and 11 deletions

View File

@ -119,7 +119,7 @@ class Vector(object):
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")
@ -130,7 +130,7 @@ class Vector(object):
"""
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

View File

@ -45,7 +45,7 @@ class Test(unittest.TestCase):
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):
"""
@ -156,13 +156,6 @@ class Test(unittest.TestCase):
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()