mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 18:49:26 +08:00
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038) * refactor: Fix naming conventions (#7038) * Update arithmetic_analysis/lu_decomposition.py Co-authored-by: Christian Clauss <cclauss@me.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038) * chore: Fix naming conventions in doctests (#7038) * fix: Temporarily disable project euler problem 104 (#7069) * chore: Fix naming conventions in doctests (#7038) Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -85,13 +85,13 @@ class Test(unittest.TestCase):
|
||||
self.assertEqual(str(x * 3.0), "(3.0,6.0,9.0)")
|
||||
self.assertEqual((a * b), 0)
|
||||
|
||||
def test_zeroVector(self) -> None:
|
||||
def test_zero_vector(self) -> None:
|
||||
"""
|
||||
test for global function zero_vector()
|
||||
"""
|
||||
self.assertTrue(str(zero_vector(10)).count("0") == 10)
|
||||
|
||||
def test_unitBasisVector(self) -> None:
|
||||
def test_unit_basis_vector(self) -> None:
|
||||
"""
|
||||
test for global function unit_basis_vector()
|
||||
"""
|
||||
@ -113,7 +113,7 @@ class Test(unittest.TestCase):
|
||||
y = x.copy()
|
||||
self.assertEqual(str(x), str(y))
|
||||
|
||||
def test_changeComponent(self) -> None:
|
||||
def test_change_component(self) -> None:
|
||||
"""
|
||||
test for method change_component()
|
||||
"""
|
||||
@ -126,77 +126,77 @@ class Test(unittest.TestCase):
|
||||
"""
|
||||
test for Matrix method str()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual("|1,2,3|\n|2,4,5|\n|6,7,8|\n", str(A))
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual("|1,2,3|\n|2,4,5|\n|6,7,8|\n", str(a))
|
||||
|
||||
def test_minor(self) -> None:
|
||||
"""
|
||||
test for Matrix method minor()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
minors = [[-3, -14, -10], [-5, -10, -5], [-2, -1, 0]]
|
||||
for x in range(A.height()):
|
||||
for y in range(A.width()):
|
||||
self.assertEqual(minors[x][y], A.minor(x, y))
|
||||
for x in range(a.height()):
|
||||
for y in range(a.width()):
|
||||
self.assertEqual(minors[x][y], a.minor(x, y))
|
||||
|
||||
def test_cofactor(self) -> None:
|
||||
"""
|
||||
test for Matrix method cofactor()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
cofactors = [[-3, 14, -10], [5, -10, 5], [-2, 1, 0]]
|
||||
for x in range(A.height()):
|
||||
for y in range(A.width()):
|
||||
self.assertEqual(cofactors[x][y], A.cofactor(x, y))
|
||||
for x in range(a.height()):
|
||||
for y in range(a.width()):
|
||||
self.assertEqual(cofactors[x][y], a.cofactor(x, y))
|
||||
|
||||
def test_determinant(self) -> None:
|
||||
"""
|
||||
test for Matrix method determinant()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual(-5, A.determinant())
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual(-5, a.determinant())
|
||||
|
||||
def test__mul__matrix(self) -> None:
|
||||
"""
|
||||
test for Matrix * operator
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3, 3)
|
||||
a = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3, 3)
|
||||
x = Vector([1, 2, 3])
|
||||
self.assertEqual("(14,32,50)", str(A * x))
|
||||
self.assertEqual("|2,4,6|\n|8,10,12|\n|14,16,18|\n", str(A * 2))
|
||||
self.assertEqual("(14,32,50)", str(a * x))
|
||||
self.assertEqual("|2,4,6|\n|8,10,12|\n|14,16,18|\n", str(a * 2))
|
||||
|
||||
def test_change_component_matrix(self) -> None:
|
||||
"""
|
||||
test for Matrix method change_component()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
A.change_component(0, 2, 5)
|
||||
self.assertEqual("|1,2,5|\n|2,4,5|\n|6,7,8|\n", str(A))
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
a.change_component(0, 2, 5)
|
||||
self.assertEqual("|1,2,5|\n|2,4,5|\n|6,7,8|\n", str(a))
|
||||
|
||||
def test_component_matrix(self) -> None:
|
||||
"""
|
||||
test for Matrix method component()
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual(7, A.component(2, 1), 0.01)
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
self.assertEqual(7, a.component(2, 1), 0.01)
|
||||
|
||||
def test__add__matrix(self) -> None:
|
||||
"""
|
||||
test for Matrix + operator
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
B = Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]], 3, 3)
|
||||
self.assertEqual("|2,4,10|\n|4,8,10|\n|12,14,18|\n", str(A + B))
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
b = Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]], 3, 3)
|
||||
self.assertEqual("|2,4,10|\n|4,8,10|\n|12,14,18|\n", str(a + b))
|
||||
|
||||
def test__sub__matrix(self) -> None:
|
||||
"""
|
||||
test for Matrix - operator
|
||||
"""
|
||||
A = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
B = Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]], 3, 3)
|
||||
self.assertEqual("|0,0,-4|\n|0,0,0|\n|0,0,-2|\n", str(A - B))
|
||||
a = Matrix([[1, 2, 3], [2, 4, 5], [6, 7, 8]], 3, 3)
|
||||
b = Matrix([[1, 2, 7], [2, 4, 5], [6, 7, 10]], 3, 3)
|
||||
self.assertEqual("|0,0,-4|\n|0,0,0|\n|0,0,-2|\n", str(a - b))
|
||||
|
||||
def test_squareZeroMatrix(self) -> None:
|
||||
def test_square_zero_matrix(self) -> None:
|
||||
"""
|
||||
test for global function square_zero_matrix()
|
||||
"""
|
||||
|
Reference in New Issue
Block a user