From 12c42c6c0a355c4ba84f0e1fba8ecaa283736a91 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:04:13 +0530 Subject: [PATCH 01/11] Update strassen_matrix_multiplication.py --- divide_and_conquer/strassen_matrix_multiplication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/divide_and_conquer/strassen_matrix_multiplication.py b/divide_and_conquer/strassen_matrix_multiplication.py index ca10e04abcbc..17efcfc7c8ee 100644 --- a/divide_and_conquer/strassen_matrix_multiplication.py +++ b/divide_and_conquer/strassen_matrix_multiplication.py @@ -114,7 +114,7 @@ def strassen(matrix1: list, matrix2: list) -> list: """ if matrix_dimensions(matrix1)[1] != matrix_dimensions(matrix2)[0]: raise Exception( - f"Unable to multiply these matrices, please check the dimensions. \n" + "Unable to multiply these matrices, please check the dimensions. \n" f"Matrix A:{matrix1} \nMatrix B:{matrix2}" ) dimension1 = matrix_dimensions(matrix1) From ec52e7845ce1096b00f30fb747c49d5fe67ddce3 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:04:32 +0530 Subject: [PATCH 02/11] Update matrix_operation.py --- matrix/matrix_operation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matrix/matrix_operation.py b/matrix/matrix_operation.py index 6d0cd4e655eb..8e5d0f583486 100644 --- a/matrix/matrix_operation.py +++ b/matrix/matrix_operation.py @@ -171,7 +171,7 @@ def _verify_matrix_sizes( shape = _shape(matrix_a) + _shape(matrix_b) if shape[0] != shape[3] or shape[1] != shape[2]: raise ValueError( - f"operands could not be broadcast together with shape " + "operands could not be broadcast together with shape " f"({shape[0], shape[1]}), ({shape[2], shape[3]})" ) return (shape[0], shape[2]), (shape[1], shape[3]) From 54ba0ec146aa9b977f1fb22df6b8eedb2342e3b5 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:04:59 +0530 Subject: [PATCH 03/11] Update enigma_machine2.py --- ciphers/enigma_machine2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciphers/enigma_machine2.py b/ciphers/enigma_machine2.py index 9252dd0edbf7..76c8016004bc 100644 --- a/ciphers/enigma_machine2.py +++ b/ciphers/enigma_machine2.py @@ -94,7 +94,7 @@ def _validator( rotorpos1, rotorpos2, rotorpos3 = rotpos if not 0 < rotorpos1 <= len(abc): raise ValueError( - f"First rotor position is not within range of 1..26 (" f"{rotorpos1}" + "First rotor position is not within range of 1..26 (" f"{rotorpos1}" ) if not 0 < rotorpos2 <= len(abc): raise ValueError( From 05d0f639d0faa9f2d17814c37ff15889e6306a36 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:07:51 +0530 Subject: [PATCH 04/11] Update enigma_machine.py --- hashes/enigma_machine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashes/enigma_machine.py b/hashes/enigma_machine.py index d1cb6efc2e8d..b0d45718e286 100644 --- a/hashes/enigma_machine.py +++ b/hashes/enigma_machine.py @@ -55,5 +55,5 @@ def engine(input_character): print("\n" + "".join(code)) print( f"\nYour Token is {token} please write it down.\nIf you want to decode " - f"this message again you should input same digits as token!" + "this message again you should input same digits as token!" ) From 5086c488a1064db8d6fad17657a50d62f2b2e372 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:09:00 +0530 Subject: [PATCH 05/11] Update enigma_machine2.py --- ciphers/enigma_machine2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ciphers/enigma_machine2.py b/ciphers/enigma_machine2.py index 76c8016004bc..70f84752d55b 100644 --- a/ciphers/enigma_machine2.py +++ b/ciphers/enigma_machine2.py @@ -98,11 +98,11 @@ def _validator( ) if not 0 < rotorpos2 <= len(abc): raise ValueError( - f"Second rotor position is not within range of 1..26 (" f"{rotorpos2})" + "Second rotor position is not within range of 1..26 (" f"{rotorpos2})" ) if not 0 < rotorpos3 <= len(abc): raise ValueError( - f"Third rotor position is not within range of 1..26 (" f"{rotorpos3})" + "Third rotor position is not within range of 1..26 (" f"{rotorpos3})" ) # Validates string and returns dict From 8c2c9aede1bc5a456e4810503dc13b93bbd2b00c Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:10:16 +0530 Subject: [PATCH 06/11] Update rod_cutting.py --- dynamic_programming/rod_cutting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamic_programming/rod_cutting.py b/dynamic_programming/rod_cutting.py index 442a39cb1616..79104d8f4044 100644 --- a/dynamic_programming/rod_cutting.py +++ b/dynamic_programming/rod_cutting.py @@ -181,7 +181,7 @@ def _enforce_args(n: int, prices: list): if n > len(prices): raise ValueError( - f"Each integral piece of rod must have a corresponding " + "Each integral piece of rod must have a corresponding " f"price. Got n = {n} but length of prices = {len(prices)}" ) From 2de2a5321545600652443aa6f3b39edd8e9df160 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:11:07 +0530 Subject: [PATCH 07/11] Update external_sort.py --- sorts/external_sort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorts/external_sort.py b/sorts/external_sort.py index 060e67adf827..7af7dc0a609d 100644 --- a/sorts/external_sort.py +++ b/sorts/external_sort.py @@ -41,7 +41,7 @@ def split(self, block_size, sort_key=None): i += 1 def cleanup(self): - map(lambda f: os.remove(f), self.block_filenames) + map(os.remove, self.block_filenames) class NWayMerge: From f002602d98e76e26c6352617b69616a1563f19b5 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:11:59 +0530 Subject: [PATCH 08/11] Update sol1.py --- project_euler/problem_067/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_067/sol1.py b/project_euler/problem_067/sol1.py index ebfa865a9479..527d4dc592ac 100644 --- a/project_euler/problem_067/sol1.py +++ b/project_euler/problem_067/sol1.py @@ -29,7 +29,7 @@ def solution(): triangle = f.readlines() a = map(lambda x: x.rstrip("\r\n").split(" "), triangle) - a = list(map(lambda x: list(map(lambda y: int(y), x)), a)) + a = list(map(lambda x: list(map(int, x)), a)) for i in range(1, len(a)): for j in range(len(a[i])): From ce41f99a334fce4a2f28655e211b1cd994a44ab7 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:12:34 +0530 Subject: [PATCH 09/11] Update hill_cipher.py --- ciphers/hill_cipher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ciphers/hill_cipher.py b/ciphers/hill_cipher.py index bc8f5b41b624..d8e436e92c56 100644 --- a/ciphers/hill_cipher.py +++ b/ciphers/hill_cipher.py @@ -62,7 +62,7 @@ class HillCipher: # take x and return x % len(key_string) modulus = numpy.vectorize(lambda x: x % 36) - to_int = numpy.vectorize(lambda x: round(x)) + to_int = numpy.vectorize(round) def __init__(self, encrypt_key: numpy.ndarray) -> None: """ From ce6dc60d78c78821df7858ba44994073cb50508e Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:13:10 +0530 Subject: [PATCH 10/11] Update prime_numbers.py --- data_structures/hashing/number_theory/prime_numbers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/hashing/number_theory/prime_numbers.py b/data_structures/hashing/number_theory/prime_numbers.py index db4d40f475b2..bf614e7d48df 100644 --- a/data_structures/hashing/number_theory/prime_numbers.py +++ b/data_structures/hashing/number_theory/prime_numbers.py @@ -14,7 +14,7 @@ def check_prime(number): elif number == special_non_primes[-1]: return 3 - return all([number % i for i in range(2, number)]) + return all(number % i for i in range(2, number)) def next_prime(value, factor=1, **kwargs): From d55bced7f3076b59597740bf48e501cd0956e305 Mon Sep 17 00:00:00 2001 From: Omkaar <79257339+Pysics@users.noreply.github.com> Date: Fri, 6 May 2022 16:16:03 +0530 Subject: [PATCH 11/11] Update integration_by_simpson_approx.py --- maths/integration_by_simpson_approx.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/maths/integration_by_simpson_approx.py b/maths/integration_by_simpson_approx.py index da0e1cffde02..c89b9e03e7b0 100644 --- a/maths/integration_by_simpson_approx.py +++ b/maths/integration_by_simpson_approx.py @@ -92,16 +92,12 @@ def simpson_integration(function, a: float, b: float, precision: int = 4) -> flo assert callable( function ), f"the function(object) passed should be callable your input : {function}" - assert isinstance(a, float) or isinstance( - a, int - ), f"a should be float or integer your input : {a}" - assert isinstance(function(a), float) or isinstance(function(a), int), ( + assert isinstance(a, (float, int)), f"a should be float or integer your input : {a}" + assert isinstance(function(a), (float, int)), ( "the function should return integer or float return type of your function, " f"{type(a)}" ) - assert isinstance(b, float) or isinstance( - b, int - ), f"b should be float or integer your input : {b}" + assert isinstance(b, (float, int)), f"b should be float or integer your input : {b}" assert ( isinstance(precision, int) and precision > 0 ), f"precision should be positive integer your input : {precision}"