Skip to content

Commit 991f3cc

Browse files
algobytewisegithub-actionscclauss
authored andcommitted
[mypy] fix small folders (TheAlgorithms#4292)
* add final else-statement * fix file_transfer * fix quantum folder * fix divide_and_conquer-folder * Update build.yml * updating DIRECTORY.md * Update ripple_adder_classic.py * Update .github/workflows/build.yml * removed imports from typing * removed conversion to string * Revert "removed conversion to string" This reverts commit 2f7c473. * implemented suggested changes * Update receive_file.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent 1291faf commit 991f3cc

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

.github/workflows/build.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ jobs:
3030
cellular_automata
3131
compression
3232
computer_vision
33+
divide_and_conquer
34+
electronics
35+
file_transfer
3336
fractals
3437
fuzzy_logic
3538
genetic_algorithm
3639
geodesy
3740
knapsack
3841
networking_flow
39-
scheduling sorts
42+
quantum
43+
scheduling
44+
sorts
4045
- name: Run tests
4146
run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. .
4247
- if: ${{ success() }}

divide_and_conquer/max_difference_pair.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from typing import List
2-
3-
4-
def max_difference(a: List[int]) -> (int, int):
1+
def max_difference(a: list[int]) -> tuple[int, int]:
52
"""
63
We are given an array A[1..n] of integers, n >= 1. We want to
74
find a pair of indices (i, j) such that

divide_and_conquer/strassen_matrix_multiplication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def strassen(matrix1: list, matrix2: list) -> list:
121121
dimension2 = matrix_dimensions(matrix2)
122122

123123
if dimension1[0] == dimension1[1] and dimension2[0] == dimension2[1]:
124-
return matrix1, matrix2
124+
return [matrix1, matrix2]
125125

126126
maximum = max(max(dimension1), max(dimension2))
127127
maxim = int(math.pow(2, math.ceil(math.log2(maximum))))

electronics/electric_power.py

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def electric_power(voltage: float, current: float, power: float) -> Tuple:
4242
return result("current", power / voltage)
4343
elif power == 0:
4444
return result("power", float(round(abs(voltage * current), 2)))
45+
else:
46+
raise ValueError("Exactly one argument must be 0")
4547

4648

4749
if __name__ == "__main__":

electronics/ohms_law.py

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, flo
3232
return {"current": voltage / resistance}
3333
elif resistance == 0:
3434
return {"resistance": voltage / current}
35+
else:
36+
raise ValueError("Exactly one argument must be 0")
3537

3638

3739
if __name__ == "__main__":

file_transfer/receive_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
print("Receiving data...")
1414
while True:
1515
data = sock.recv(1024)
16-
print(f"data={data}")
16+
print(f"{data = }")
1717
if not data:
1818
break
1919
out_file.write(data) # Write data to a file

file_transfer/send_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
1313
conn, addr = sock.accept() # Establish connection with client.
1414
print(f"Got connection from {addr}")
1515
data = conn.recv(1024)
16-
print(f"Server received {data}")
16+
print(f"Server received: {data = }")
1717

1818
with open(filename, "rb") as in_file:
1919
data = in_file.read(1024)

quantum/ripple_adder_classic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from qiskit.providers import BaseBackend
77

88

9-
def store_two_classics(val1: int, val2: int) -> (QuantumCircuit, str, str):
9+
def store_two_classics(val1: int, val2: int) -> tuple[QuantumCircuit, str, str]:
1010
"""
1111
Generates a Quantum Circuit which stores two classical integers
1212
Returns the circuit and binary representation of the integers

0 commit comments

Comments
 (0)