From 2a1466f953411fec54ca504cea5c39e0c1a4fedc Mon Sep 17 00:00:00 2001 From: onlinejudge95 Date: Tue, 11 Feb 2020 16:49:25 +0530 Subject: [PATCH 1/4] Fixes black failures from Previous PR --- dynamic_programming/optimal_binary_search_tree.py | 1 + maths/bisection.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/dynamic_programming/optimal_binary_search_tree.py b/dynamic_programming/optimal_binary_search_tree.py index b0f248acf35c..f33ca01bd933 100644 --- a/dynamic_programming/optimal_binary_search_tree.py +++ b/dynamic_programming/optimal_binary_search_tree.py @@ -24,6 +24,7 @@ class Node: """Binary Search Tree Node""" + def __init__(self, key, freq): self.key = key self.freq = freq diff --git a/maths/bisection.py b/maths/bisection.py index a9df15b775b3..93cc2247b64e 100644 --- a/maths/bisection.py +++ b/maths/bisection.py @@ -6,6 +6,8 @@ https://en.wikipedia.org/wiki/Bisection_method """ + + def equation(x: float) -> float: """ >>> equation(5) From 1919e0fc99d2d942b892e6e9f1d6bd51425149e2 Mon Sep 17 00:00:00 2001 From: onlinejudge95 Date: Tue, 11 Feb 2020 17:04:05 +0530 Subject: [PATCH 2/4] Fixes equality testing alert --- data_structures/binary_tree/binary_search_tree.py | 4 ++-- hashes/hamming_code.py | 4 ++-- strings/aho-corasick.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data_structures/binary_tree/binary_search_tree.py b/data_structures/binary_tree/binary_search_tree.py index 46c5ccca032c..86dcd6489bd5 100644 --- a/data_structures/binary_tree/binary_search_tree.py +++ b/data_structures/binary_tree/binary_search_tree.py @@ -56,13 +56,13 @@ def __insert(self, value): parent_node = self.root # from root while True: # While we don't get to a leaf if value < parent_node.value: # We go left - if parent_node.left == None: + if parent_node.left is None: parent_node.left = new_node # We insert the new node in a leaf break else: parent_node = parent_node.left else: - if parent_node.right == None: + if parent_node.right is None: parent_node.right = new_node break else: diff --git a/hashes/hamming_code.py b/hashes/hamming_code.py index aae39ed9a06f..756ba7c6670f 100644 --- a/hashes/hamming_code.py +++ b/hashes/hamming_code.py @@ -140,7 +140,7 @@ def emitterConverter(sizePar, data): # Mount the message ContBP = 0 # parity bit counter for x in range(0, sizePar + len(data)): - if dataOrd[x] == None: + if dataOrd[x] is None: dataOut.append(str(parity[ContBP])) ContBP += 1 else: @@ -243,7 +243,7 @@ def receptorConverter(sizePar, data): # Mount the message ContBP = 0 # Parity bit counter for x in range(0, sizePar + len(dataOutput)): - if dataOrd[x] == None: + if dataOrd[x] is None: dataOut.append(str(parity[ContBP])) ContBP += 1 else: diff --git a/strings/aho-corasick.py b/strings/aho-corasick.py index 315f7793325e..bb6955bdd423 100644 --- a/strings/aho-corasick.py +++ b/strings/aho-corasick.py @@ -47,7 +47,7 @@ def set_fail_transitions(self): q.append(child) state = self.adlist[r]["fail_state"] while ( - self.find_next_state(state, self.adlist[child]["value"]) == None + self.find_next_state(state, self.adlist[child]["value"]) is None and state != 0 ): state = self.adlist[state]["fail_state"] From f2141123a6d0f5e5f0f0df7136d260ff7c64bc7d Mon Sep 17 00:00:00 2001 From: onlinejudge95 Date: Tue, 11 Feb 2020 17:07:01 +0530 Subject: [PATCH 3/4] Fixes call to main() alert --- searches/tabu_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index 04a0e5076912..e8fcfd01aa4d 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -278,4 +278,4 @@ def main(args=None): ) # Pass the arguments to main method - sys.exit(main(parser.parse_args())) + main(parser.parse_args()) From 6f7652196258fc9839c5904e882ecb7e85715ec6 Mon Sep 17 00:00:00 2001 From: onlinejudge95 Date: Tue, 11 Feb 2020 18:53:41 +0530 Subject: [PATCH 4/4] Fixes unused import --- searches/tabu_search.py | 1 - 1 file changed, 1 deletion(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index e8fcfd01aa4d..2847dca7acd7 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -25,7 +25,6 @@ import copy import argparse -import sys def generate_neighbours(path):