From d0f5b6ad523dae98f0e4e8d91ae0d0a8ac598a5c Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 19 May 2020 00:42:36 +0800 Subject: [PATCH 1/5] change doctest line import doctest is not relevant with algorithms. move it under main section. --- blockchain/chinese_remainder_theorem.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blockchain/chinese_remainder_theorem.py b/blockchain/chinese_remainder_theorem.py index 8c3eb9b4b01e..fedebd358cbd 100644 --- a/blockchain/chinese_remainder_theorem.py +++ b/blockchain/chinese_remainder_theorem.py @@ -81,10 +81,9 @@ def chinese_remainder_theorem2(n1, r1, n2, r2): return (n % m + m) % m -# import testmod for testing our function -from doctest import testmod - if __name__ == "__main__": + # import testmod for testing our function + from doctest import testmod testmod(name="chinese_remainder_theorem", verbose=True) testmod(name="chinese_remainder_theorem2", verbose=True) testmod(name="invert_modulo", verbose=True) From 3ce4ce8bb05c65e815ba6b387dda1a1b151301cc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 18 May 2020 21:15:02 +0200 Subject: [PATCH 2/5] from doctest import testmod --- blockchain/chinese_remainder_theorem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/chinese_remainder_theorem.py b/blockchain/chinese_remainder_theorem.py index fedebd358cbd..2b1e66ebea02 100644 --- a/blockchain/chinese_remainder_theorem.py +++ b/blockchain/chinese_remainder_theorem.py @@ -82,8 +82,8 @@ def chinese_remainder_theorem2(n1, r1, n2, r2): if __name__ == "__main__": - # import testmod for testing our function from doctest import testmod + testmod(name="chinese_remainder_theorem", verbose=True) testmod(name="chinese_remainder_theorem2", verbose=True) testmod(name="invert_modulo", verbose=True) From fbf53363e104293ffb925bf1fa2932f3aecfffac Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 19 May 2020 16:03:40 +0800 Subject: [PATCH 3/5] refactor: move doctest under "main" section --- blockchain/chinese_remainder_theorem.py | 1 + blockchain/diophantine_equation.py | 5 ++--- blockchain/modular_division.py | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/blockchain/chinese_remainder_theorem.py b/blockchain/chinese_remainder_theorem.py index fedebd358cbd..e9b4e5c197c9 100644 --- a/blockchain/chinese_remainder_theorem.py +++ b/blockchain/chinese_remainder_theorem.py @@ -84,6 +84,7 @@ def chinese_remainder_theorem2(n1, r1, n2, r2): if __name__ == "__main__": # import testmod for testing our function from doctest import testmod + testmod(name="chinese_remainder_theorem", verbose=True) testmod(name="chinese_remainder_theorem2", verbose=True) testmod(name="invert_modulo", verbose=True) diff --git a/blockchain/diophantine_equation.py b/blockchain/diophantine_equation.py index ec2ed26e40ec..2f1cf600d3d3 100644 --- a/blockchain/diophantine_equation.py +++ b/blockchain/diophantine_equation.py @@ -118,10 +118,9 @@ def extended_gcd(a, b): return (d, x, y) -# import testmod for testing our function -from doctest import testmod - if __name__ == "__main__": + # import testmod for testing our function + from doctest import testmod testmod(name="diophantine", verbose=True) testmod(name="diophantine_all_soln", verbose=True) testmod(name="extended_gcd", verbose=True) diff --git a/blockchain/modular_division.py b/blockchain/modular_division.py index 1255f04328d5..dd846461d02b 100644 --- a/blockchain/modular_division.py +++ b/blockchain/modular_division.py @@ -139,10 +139,9 @@ def greatest_common_divisor(a, b): return b -# Import testmod for testing our function -from doctest import testmod - if __name__ == "__main__": + # Import testmod for testing our function + from doctest import testmod testmod(name="modular_division", verbose=True) testmod(name="modular_division2", verbose=True) testmod(name="invert_modulo", verbose=True) From 701b7687c13f370d000b140525f582ea93f2524d Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 19 May 2020 12:55:32 +0200 Subject: [PATCH 4/5] Update diophantine_equation.py --- blockchain/diophantine_equation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/blockchain/diophantine_equation.py b/blockchain/diophantine_equation.py index 576e7fb434cf..dab4b3a65fb2 100644 --- a/blockchain/diophantine_equation.py +++ b/blockchain/diophantine_equation.py @@ -119,7 +119,6 @@ def extended_gcd(a, b): if __name__ == "__main__": - # import testmod for testing our function from doctest import testmod testmod(name="diophantine", verbose=True) From db1a02c31e2f9e86aa823fa6a85d9145a9dc6052 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 19 May 2020 12:55:59 +0200 Subject: [PATCH 5/5] Update modular_division.py --- blockchain/modular_division.py | 1 - 1 file changed, 1 deletion(-) diff --git a/blockchain/modular_division.py b/blockchain/modular_division.py index 0e4f2abc83c7..c81c2138d1a8 100644 --- a/blockchain/modular_division.py +++ b/blockchain/modular_division.py @@ -140,7 +140,6 @@ def greatest_common_divisor(a, b): if __name__ == "__main__": - # Import testmod for testing our function from doctest import testmod testmod(name="modular_division", verbose=True)