From 76b76df328352d03077b5c0e22f688a3a03b5283 Mon Sep 17 00:00:00 2001 From: Ayush Raj Date: Wed, 3 Feb 2021 02:38:01 +0530 Subject: [PATCH 1/3] [mypy] Add/fix type annotations for boolean_algebra --- boolean_algebra/quine_mc_cluskey.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index 19bac336f6c5..821c953d6e76 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -1,3 +1,5 @@ +from typing import List + def compare_string(string1: str, string2: str) -> str: """ >>> compare_string('0010','0110') @@ -14,12 +16,12 @@ def compare_string(string1: str, string2: str) -> str: count += 1 l1[i] = "_" if count > 1: - return -1 + return "X" else: return "".join(l1) -def check(binary: [str]) -> [str]: +def check(binary: List[str]) -> List[str]: """ >>> check(['0.00.01.5']) ['0.00.01.5'] @@ -31,7 +33,7 @@ def check(binary: [str]) -> [str]: for i in range(len(binary)): for j in range(i + 1, len(binary)): k = compare_string(binary[i], binary[j]) - if k != -1: + if k != "X": check1[i] = "*" check1[j] = "*" temp.append(k) @@ -43,7 +45,7 @@ def check(binary: [str]) -> [str]: binary = list(set(temp)) -def decimal_to_binary(no_of_variable: int, minterms: [float]) -> [str]: +def decimal_to_binary(no_of_variable: int, minterms: List[float]) -> List[str]: """ >>> decimal_to_binary(3,[1.5]) ['0.00.01.5'] @@ -79,7 +81,7 @@ def is_for_table(string1: str, string2: str, count: int) -> bool: return False -def selection(chart: [[int]], prime_implicants: [str]) -> [str]: +def selection(chart: List[List[int]], prime_implicants: List[str]) -> List[str]: """ >>> selection([[1]],['0.00.01.5']) ['0.00.01.5'] @@ -126,7 +128,7 @@ def selection(chart: [[int]], prime_implicants: [str]) -> [str]: chart[j][i] = 0 -def prime_implicant_chart(prime_implicants: [str], binary: [str]) -> [[int]]: +def prime_implicant_chart(prime_implicants: List[str], binary: List[str]) -> List[List[int]]: """ >>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5']) [[1]] From dc17c67d7538dfeefc5792c00a7dabcbdac51ebc Mon Sep 17 00:00:00 2001 From: Ayush Raj Date: Wed, 3 Feb 2021 03:30:00 +0530 Subject: [PATCH 2/3] [mypy] Add/fix type annotations for boolean_algebra --- boolean_algebra/quine_mc_cluskey.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index 821c953d6e76..1b9d541bf326 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -1,5 +1,6 @@ from typing import List + def compare_string(string1: str, string2: str) -> str: """ >>> compare_string('0010','0110') @@ -128,7 +129,9 @@ def selection(chart: List[List[int]], prime_implicants: List[str]) -> List[str]: chart[j][i] = 0 -def prime_implicant_chart(prime_implicants: List[str], binary: List[str]) -> List[List[int]]: +def prime_implicant_chart( + prime_implicants: List[str], binary: List[str] +) -> List[List[int]]: """ >>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5']) [[1]] From 1ef42433a636770926cf8ea008eb4d55f4186c9f Mon Sep 17 00:00:00 2001 From: Ayush Raj Date: Wed, 3 Feb 2021 03:55:23 +0530 Subject: [PATCH 3/3] [mypy] Add/fix annotations for boolean_algebra --- boolean_algebra/quine_mc_cluskey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index 1b9d541bf326..70cdf25a701d 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -7,7 +7,7 @@ def compare_string(string1: str, string2: str) -> str: '0_10' >>> compare_string('0110','1101') - -1 + 'X' """ l1 = list(string1) l2 = list(string2)