Skip to content

Commit 43bc413

Browse files
committed
Merge branch 'feature/style' into develop
2 parents 5ebfe70 + dae1b3b commit 43bc413

12 files changed

+112
-75
lines changed

python-algorithm/algorithm/greedy/test/test_cashier_change.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55

66
@pytest.mark.benchmark(group="cashier_change")
7-
@pytest.mark.parametrize("denominations, price, expected", [
8-
([25, 10, 5, 1], 30, 2),
9-
([25, 10, 5, 1], 24, 6),
10-
], ids=["successful1", "successful2"])
7+
@pytest.mark.parametrize(
8+
argnames="denominations, price, expected",
9+
argvalues=[
10+
([25, 10, 5, 1], 30, 2),
11+
([25, 10, 5, 1], 24, 6)
12+
],
13+
ids=["case1", "case2"])
1114
def test_cashier_change(benchmark, denominations, price, expected):
1215
result = benchmark(cashier_change, denominations, price)
1316
assert expected == result

python-algorithm/algorithm/greedy/test/test_interval_schedule.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717

1818
@pytest.mark.benchmark(group="interval_scheduling_lecture")
19-
@pytest.mark.parametrize("lectures, expected", [
20-
([lecture1, lecture2, lecture3], [lecture2, lecture3]),
21-
], ids=["successful"])
19+
@pytest.mark.parametrize(
20+
argnames="lectures, expected",
21+
argvalues=[([lecture1, lecture2, lecture3], [lecture2, lecture3])],
22+
ids=["case1"])
2223
def test_interval_scheduling_lecture(benchmark, lectures, expected):
2324
result = benchmark(interval_scheduling_lecture, lectures)
2425
assert expected == result

python-algorithm/algorithm/math/test/test_addition_integer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55

66
@pytest.mark.benchmark(group="addition_of_binary_number")
7-
@pytest.mark.parametrize("a, b, expected", [
8-
('1110', '1011', '11001'),
9-
], ids=["successful"])
7+
@pytest.mark.parametrize(
8+
argnames="a, b, expected",
9+
argvalues=[('1110', '1011', '11001')],
10+
ids=["case1"])
1011
def test_addition_of_binary_number(benchmark, a, b, expected):
1112
result = benchmark(addition_binary_number, a, b)
1213
assert expected == result

python-algorithm/algorithm/math/test/test_base_expansion.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55

66
@pytest.mark.benchmark(group="base_expansion")
7-
@pytest.mark.parametrize("number, base, expected", [
8-
(12345, 8, '30071'),
9-
(177130, 16, '2B3EA'),
10-
(241, 2, '11110001'),
11-
], ids=["base8", "base16", "base2"])
7+
@pytest.mark.parametrize(
8+
argnames="number, base, expected",
9+
argvalues=[
10+
(12345, 8, '30071'),
11+
(177130, 16, '2B3EA'),
12+
(241, 2, '11110001')
13+
],
14+
ids=["base8", "base16", "base2"])
1215
def test_base_expansion(benchmark, number, base, expected):
1316
result = benchmark(base_expansion, number, base)
1417
assert expected == result

python-algorithm/algorithm/math/test/test_greatest_common_divisor.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,41 @@
44

55

66
@pytest.mark.benchmark(group="gcd_euclidean")
7-
@pytest.mark.parametrize("pair, expected", [
8-
((24, 36), 12),
9-
((17, 22), 1),
10-
((120, 500), 20),
11-
])
7+
@pytest.mark.parametrize(
8+
argnames="pair, expected",
9+
argvalues=[
10+
((24, 36), 12),
11+
((17, 22), 1),
12+
((120, 500), 20)
13+
])
1214
def test_gcd_euclidean(benchmark, pair, expected):
1315
assert is_positive_integer(*pair) is True
1416
result = benchmark(gcd_euclidean, *pair)
1517
assert expected == result
1618

1719

1820
@pytest.mark.benchmark(group="gcd_euclidean_divmod")
19-
@pytest.mark.parametrize("pair, expected", [
20-
((24, 36), 12),
21-
((17, 22), 1),
22-
((120, 500), 20),
23-
])
21+
@pytest.mark.parametrize(
22+
argnames="pair, expected",
23+
argvalues=[
24+
((24, 36), 12),
25+
((17, 22), 1),
26+
((120, 500), 20)
27+
])
2428
def test_gcd_euclidean_divmod(benchmark, pair, expected):
2529
assert is_positive_integer(*pair) is True
2630
result = benchmark(gcd_euclidean_divmod, *pair)
2731
assert expected == result
2832

2933

3034
@pytest.mark.benchmark(group="gcd_extended_euclidean")
31-
@pytest.mark.parametrize("pair, expected", [
32-
((24, 36), (12, -1, 1)),
33-
((17, 22), (1, -9, 7)),
34-
((120, 500), (20, -4, 1)),
35-
])
35+
@pytest.mark.parametrize(
36+
argnames="pair, expected",
37+
argvalues=[
38+
((24, 36), (12, -1, 1)),
39+
((17, 22), (1, -9, 7)),
40+
((120, 500), (20, -4, 1))
41+
])
3642
def test_gcd_extended_euclidean(benchmark, pair, expected):
3743
assert is_positive_integer(*pair) is True
3844
result = benchmark(gcd_extended_euclidean, *pair)

python-algorithm/algorithm/math/test/test_least_common_multiple.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55

66
@pytest.mark.benchmark(group="lcm")
7-
@pytest.mark.parametrize("pair, expected", [
8-
((24, 36), 72),
9-
((17, 22), 374),
10-
((120, 500), 3000),
11-
])
7+
@pytest.mark.parametrize(
8+
argnames="pair, expected",
9+
argvalues=[
10+
((24, 36), 72),
11+
((17, 22), 374),
12+
((120, 500), 3000)
13+
])
1214
def test_lcm(benchmark, pair, expected):
1315
assert is_positive_integer(*pair) is True
1416
result = benchmark(lcm, *pair)

python-algorithm/algorithm/math/test/test_matrix_multiplication.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99

1010

1111
@pytest.mark.benchmark(group="matrix_multiplication")
12-
@pytest.mark.parametrize("a, b, expected", [
13-
(matrix_a, matrix_b, matrix_ab),
14-
], ids=["multiply_matrix"])
12+
@pytest.mark.parametrize(
13+
argnames="a, b, expected",
14+
argvalues=[(matrix_a, matrix_b, matrix_ab)],
15+
ids=["multiply_matrix"])
1516
def test_matrix_multiplication1(benchmark, a, b, expected):
1617
result = benchmark(multiply_matrix, a, b)
1718
assert np.array_equal(expected, result)
1819

1920

2021
@pytest.mark.benchmark(group="matrix_multiplication")
21-
@pytest.mark.parametrize("a, b, expected", [
22-
(matrix_a, matrix_b, matrix_ab),
23-
], ids=["np.dot"])
22+
@pytest.mark.parametrize(
23+
argnames="a, b, expected",
24+
argvalues=[(matrix_a, matrix_b, matrix_ab)],
25+
ids=["np.dot"])
2426
def test_matrix_multiplication2(benchmark, a, b, expected):
2527
result = benchmark(np.dot, a, b)
2628
assert np.array_equal(expected, result)

python-algorithm/algorithm/search/test/test_binary_search.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55

66
@pytest.mark.benchmark(group="binary_search")
7-
@pytest.mark.parametrize("sequence, target, expected", [
8-
([1, 2, 3, 4, 5], 5, 4),
9-
([1, 2, 3, 4, 5], 6, -1),
10-
], ids=["successful1", "successful2"])
7+
@pytest.mark.parametrize(
8+
argnames="sequence, target, expected",
9+
argvalues=[
10+
([1, 2, 3, 4, 5], 5, 4),
11+
([1, 2, 3, 4, 5], 6, -1)
12+
],
13+
ids=["case1", "case2"])
1114
def test_binary_search(benchmark, sequence, target, expected):
1215
result = benchmark(binary_search, sequence, target)
1316
assert expected == result

python-algorithm/algorithm/search/test/test_dna_search.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,34 @@
33

44

55
@pytest.mark.benchmark(group="linear_contains")
6-
@pytest.mark.parametrize("gene, key_codon, expected", [
7-
(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT"),
8-
(Nucleotide.A, Nucleotide.C, Nucleotide.G),
9-
True),
10-
(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT"),
11-
(Nucleotide.G, Nucleotide.A, Nucleotide.T),
12-
False),
13-
], ids=["successful", "failed"])
6+
@pytest.mark.parametrize(
7+
argnames="gene, key_codon, expected",
8+
argvalues=[
9+
(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT"),
10+
(Nucleotide.A, Nucleotide.C, Nucleotide.G),
11+
True),
12+
(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT"),
13+
(Nucleotide.G, Nucleotide.A, Nucleotide.T),
14+
False),
15+
],
16+
ids=["found", "not_found"])
1417
def test_linear_contains(benchmark, gene, key_codon, expected):
1518
result = benchmark(linear_contains, gene, key_codon)
1619
assert expected == result
1720

1821

1922
@pytest.mark.benchmark(group="binary_contains")
20-
@pytest.mark.parametrize("gene, key_codon, expected", [
21-
(sorted(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT")),
22-
(Nucleotide.A, Nucleotide.C, Nucleotide.G),
23-
True),
24-
(sorted(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT")),
25-
(Nucleotide.G, Nucleotide.A, Nucleotide.T),
26-
False),
27-
], ids=["successful", "failed"])
23+
@pytest.mark.parametrize(
24+
argnames="gene, key_codon, expected",
25+
argvalues=[
26+
(sorted(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT")),
27+
(Nucleotide.A, Nucleotide.C, Nucleotide.G),
28+
True),
29+
(sorted(string_to_gene("ACGTGGCTCTCTAACGTACGTACGTACGGGGTTTATATATACCCTAGGACTCCCTTT")),
30+
(Nucleotide.G, Nucleotide.A, Nucleotide.T),
31+
False),
32+
],
33+
ids=["found", "not_found"])
2834
def test_binary_contains(benchmark, gene, key_codon, expected):
2935
result = benchmark(binary_contains, gene, key_codon)
3036
assert expected == result

python-algorithm/algorithm/search/test/test_generic_search.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33

44

55
@pytest.mark.benchmark(group="linear_contains")
6-
@pytest.mark.parametrize("elements, target, expected", [
7-
([1, 5, 15, 15, 15, 15, 20], 5, True),
8-
], ids=["successful"])
6+
@pytest.mark.parametrize(
7+
argnames="elements, target, expected",
8+
argvalues=[
9+
([1, 5, 15, 15, 15, 15, 20], 5, True)
10+
],
11+
ids=["found"])
912
def test_generic_linear_contains(benchmark, elements, target, expected):
1013
result = benchmark(generic_linear_contains, elements, target)
1114
assert expected == result
1215

1316

1417
@pytest.mark.benchmark(group="binary_contains")
15-
@pytest.mark.parametrize("elements, target, expected", [
16-
(["a", "d", "e", "f", "z"], "f", True),
17-
(["john", "mark", "ronald", "sarah"], "sheila", False),
18-
], ids=["successful", "failed"])
18+
@pytest.mark.parametrize(
19+
argnames="elements, target, expected",
20+
argvalues=[
21+
(["a", "d", "e", "f", "z"], "f", True),
22+
(["john", "mark", "ronald", "sarah"], "sheila", False)
23+
],
24+
ids=["found", "not_found"])
1925
def test_generic_binary_contains(benchmark, elements, target, expected):
2026
result = benchmark(generic_binary_contains, elements, target)
2127
assert expected == result

0 commit comments

Comments
 (0)