mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[mypy] fix small folders (#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 2f7c4731d1
.
* 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>
This commit is contained in:
parent
a8db5d4b93
commit
959507901a
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
|
@ -30,13 +30,18 @@ jobs:
|
|||
cellular_automata
|
||||
compression
|
||||
computer_vision
|
||||
divide_and_conquer
|
||||
electronics
|
||||
file_transfer
|
||||
fractals
|
||||
fuzzy_logic
|
||||
genetic_algorithm
|
||||
geodesy
|
||||
knapsack
|
||||
networking_flow
|
||||
scheduling sorts
|
||||
quantum
|
||||
scheduling
|
||||
sorts
|
||||
- name: Run tests
|
||||
run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. .
|
||||
- if: ${{ success() }}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
from typing import List
|
||||
|
||||
|
||||
def max_difference(a: List[int]) -> (int, int):
|
||||
def max_difference(a: list[int]) -> tuple[int, int]:
|
||||
"""
|
||||
We are given an array A[1..n] of integers, n >= 1. We want to
|
||||
find a pair of indices (i, j) such that
|
||||
|
|
|
@ -121,7 +121,7 @@ def strassen(matrix1: list, matrix2: list) -> list:
|
|||
dimension2 = matrix_dimensions(matrix2)
|
||||
|
||||
if dimension1[0] == dimension1[1] and dimension2[0] == dimension2[1]:
|
||||
return matrix1, matrix2
|
||||
return [matrix1, matrix2]
|
||||
|
||||
maximum = max(max(dimension1), max(dimension2))
|
||||
maxim = int(math.pow(2, math.ceil(math.log2(maximum))))
|
||||
|
|
|
@ -42,6 +42,8 @@ def electric_power(voltage: float, current: float, power: float) -> Tuple:
|
|||
return result("current", power / voltage)
|
||||
elif power == 0:
|
||||
return result("power", float(round(abs(voltage * current), 2)))
|
||||
else:
|
||||
raise ValueError("Exactly one argument must be 0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -32,6 +32,8 @@ def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, flo
|
|||
return {"current": voltage / resistance}
|
||||
elif resistance == 0:
|
||||
return {"resistance": voltage / current}
|
||||
else:
|
||||
raise ValueError("Exactly one argument must be 0")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -13,7 +13,7 @@ if __name__ == "__main__":
|
|||
print("Receiving data...")
|
||||
while True:
|
||||
data = sock.recv(1024)
|
||||
print(f"data={data}")
|
||||
print(f"{data = }")
|
||||
if not data:
|
||||
break
|
||||
out_file.write(data) # Write data to a file
|
||||
|
|
|
@ -13,7 +13,7 @@ def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
|
|||
conn, addr = sock.accept() # Establish connection with client.
|
||||
print(f"Got connection from {addr}")
|
||||
data = conn.recv(1024)
|
||||
print(f"Server received {data}")
|
||||
print(f"Server received: {data = }")
|
||||
|
||||
with open(filename, "rb") as in_file:
|
||||
data = in_file.read(1024)
|
||||
|
|
|
@ -6,7 +6,7 @@ from qiskit import Aer, QuantumCircuit, execute
|
|||
from qiskit.providers import BaseBackend
|
||||
|
||||
|
||||
def store_two_classics(val1: int, val2: int) -> (QuantumCircuit, str, str):
|
||||
def store_two_classics(val1: int, val2: int) -> tuple[QuantumCircuit, str, str]:
|
||||
"""
|
||||
Generates a Quantum Circuit which stores two classical integers
|
||||
Returns the circuit and binary representation of the integers
|
||||
|
|
Loading…
Reference in New Issue
Block a user