From 22b81b52f2c27b821dc5da9ca6ef97d91ad4f67f Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 11:42:00 +0100 Subject: [PATCH 01/30] Added boolean identity and one testcase for it --- src/main/py/logical_operations.py | 2 ++ src/test/py/test_logical_operations.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/main/py/logical_operations.py create mode 100644 src/test/py/test_logical_operations.py diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py new file mode 100644 index 0000000..a9e51a8 --- /dev/null +++ b/src/main/py/logical_operations.py @@ -0,0 +1,2 @@ +def identity(a, b): + return a diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py new file mode 100644 index 0000000..4efdb64 --- /dev/null +++ b/src/test/py/test_logical_operations.py @@ -0,0 +1,17 @@ +import unittest +from src.main.py.logical_operations import * + + +class calculationsWithRoots(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_identity_x_and_0_equals_x(self): + self.assertEqual(identity(1, 0), 1) + + +if __name__ == "__main__": + unittest.main() From 86154a6eb7f8a56e3838685d51ebd75b8da035df Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 11:45:18 +0100 Subject: [PATCH 02/30] refactoring: renamed varible and its parameters to fit function --- src/main/py/logical_operations.py | 4 ++-- src/test/py/test_logical_operations.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index a9e51a8..20d86c2 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,2 +1,2 @@ -def identity(a, b): - return a +def identity_conjunctive(variable, zero): + return variable diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 4efdb64..628b075 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -10,7 +10,7 @@ class calculationsWithRoots(unittest.TestCase): pass def test_identity_x_and_0_equals_x(self): - self.assertEqual(identity(1, 0), 1) + self.assertEqual(identity_conjunctive(1, 0), 1) if __name__ == "__main__": From 49d130a2b1fc7f114f4d6ebab791d33be780de3b Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 11:51:50 +0100 Subject: [PATCH 03/30] Added another testcase for identity and additions in code to fulfill it --- src/main/py/logical_operations.py | 5 ++++- src/test/py/test_logical_operations.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 20d86c2..a9ff3c1 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,2 +1,5 @@ def identity_conjunctive(variable, zero): - return variable + if variable == 1 and zero == 0: + return variable + else: + return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 628b075..9031510 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -12,6 +12,9 @@ class calculationsWithRoots(unittest.TestCase): def test_identity_x_and_0_equals_x(self): self.assertEqual(identity_conjunctive(1, 0), 1) + def test_identity_x_and_1_equals_NULL(self): + self.assertEqual(identity_conjunctive(1, 1), None) + if __name__ == "__main__": unittest.main() From e373aa8f53621e3179ebd395bec94e488138135a Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 11:52:27 +0100 Subject: [PATCH 04/30] Renamed functions --- src/test/py/test_logical_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 9031510..bee3116 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -9,10 +9,10 @@ class calculationsWithRoots(unittest.TestCase): def tearDown(self): pass - def test_identity_x_and_0_equals_x(self): + def test_identity_1_and_0_equals_x(self): self.assertEqual(identity_conjunctive(1, 0), 1) - def test_identity_x_and_1_equals_NULL(self): + def test_identity_1_and_1_equals_NULL(self): self.assertEqual(identity_conjunctive(1, 1), None) From 53690b597da94d4f3cc3a904edd2e03ba0aa7d70 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 11:54:28 +0100 Subject: [PATCH 05/30] Changed test function names to fit function name --- src/test/py/test_logical_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index bee3116..83cbace 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -9,10 +9,10 @@ class calculationsWithRoots(unittest.TestCase): def tearDown(self): pass - def test_identity_1_and_0_equals_x(self): + def test_conjunctive_identity_1_and_0_equals_x(self): self.assertEqual(identity_conjunctive(1, 0), 1) - def test_identity_1_and_1_equals_NULL(self): + def test_conjunctive_identity_1_and_1_equals_NULL(self): self.assertEqual(identity_conjunctive(1, 1), None) From e25964582e891d0d466bf5933f3e82e9c8173b05 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:00:10 +0100 Subject: [PATCH 06/30] Changes to function and additional test --- src/main/py/logical_operations.py | 2 +- src/test/py/test_logical_operations.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index a9ff3c1..a044004 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,5 +1,5 @@ def identity_conjunctive(variable, zero): - if variable == 1 and zero == 0: + if zero == 0: return variable else: return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 83cbace..0eda349 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -9,12 +9,15 @@ class calculationsWithRoots(unittest.TestCase): def tearDown(self): pass - def test_conjunctive_identity_1_and_0_equals_x(self): + def test_disconjunctive_identity_1_and_0_equals_x(self): self.assertEqual(identity_conjunctive(1, 0), 1) - def test_conjunctive_identity_1_and_1_equals_NULL(self): + def test_disconjunctive_identity_1_and_1_equals_NULL(self): self.assertEqual(identity_conjunctive(1, 1), None) + def test_disconjunctive_identity_1_and_1_equals_NULL(self): + self.assertEqual(identity_conjunctive(0, 1), None) + if __name__ == "__main__": unittest.main() From 5a0dcf7428c122d87a69c9ab2157117ba8f97a1c Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:01:10 +0100 Subject: [PATCH 07/30] Renamed test functions to fit testcase --- src/test/py/test_logical_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 0eda349..a66258a 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -12,10 +12,10 @@ class calculationsWithRoots(unittest.TestCase): def test_disconjunctive_identity_1_and_0_equals_x(self): self.assertEqual(identity_conjunctive(1, 0), 1) - def test_disconjunctive_identity_1_and_1_equals_NULL(self): + def test_disconjunctive_identity_1_and_1_equals_None(self): self.assertEqual(identity_conjunctive(1, 1), None) - def test_disconjunctive_identity_1_and_1_equals_NULL(self): + def test_disconjunctive_identity__and_1_equals_None(self): self.assertEqual(identity_conjunctive(0, 1), None) From 9b995995e84ddfa6a6a2a2c9782423449deb6c20 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:04:38 +0100 Subject: [PATCH 08/30] Added another testcase --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index a66258a..c21facc 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -18,6 +18,9 @@ class calculationsWithRoots(unittest.TestCase): def test_disconjunctive_identity__and_1_equals_None(self): self.assertEqual(identity_conjunctive(0, 1), None) + def test_disconjunctive_identity__and_1_equals_None(self): + self.assertEqual(identity_conjunctive(0, 0), 0) + if __name__ == "__main__": unittest.main() From 30bcb22ea065607df0763bc84c64636702652b36 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:05:59 +0100 Subject: [PATCH 09/30] refactoring: Changed function names to fit testcase --- src/test/py/test_logical_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index c21facc..35a7c7c 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -15,10 +15,10 @@ class calculationsWithRoots(unittest.TestCase): def test_disconjunctive_identity_1_and_1_equals_None(self): self.assertEqual(identity_conjunctive(1, 1), None) - def test_disconjunctive_identity__and_1_equals_None(self): + def test_disconjunctive_identity_0_and_1_equals_None(self): self.assertEqual(identity_conjunctive(0, 1), None) - def test_disconjunctive_identity__and_1_equals_None(self): + def test_disconjunctive_identity_0_and_0_equals_0(self): self.assertEqual(identity_conjunctive(0, 0), 0) From dd8e4369e0c5a6c11e0f3318aa34eb6c45002080 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:16:52 +0100 Subject: [PATCH 10/30] Added or operand functionality --- src/main/py/logical_operations.py | 4 ++-- src/test/py/test_logical_operations.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index a044004..6cbd64b 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,5 +1,5 @@ -def identity_conjunctive(variable, zero): - if zero == 0: +def identity_conjunctive(variable, operator, zero): + if zero == 0 and operator == "+": return variable else: return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 35a7c7c..84bdaaf 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -10,16 +10,16 @@ class calculationsWithRoots(unittest.TestCase): pass def test_disconjunctive_identity_1_and_0_equals_x(self): - self.assertEqual(identity_conjunctive(1, 0), 1) + self.assertEqual(identity_conjunctive(1, "+", 0), 1) def test_disconjunctive_identity_1_and_1_equals_None(self): - self.assertEqual(identity_conjunctive(1, 1), None) + self.assertEqual(identity_conjunctive(1, "+", 1), None) def test_disconjunctive_identity_0_and_1_equals_None(self): - self.assertEqual(identity_conjunctive(0, 1), None) + self.assertEqual(identity_conjunctive(0, "+", 1), None) def test_disconjunctive_identity_0_and_0_equals_0(self): - self.assertEqual(identity_conjunctive(0, 0), 0) + self.assertEqual(identity_conjunctive(0, "+", 0), 0) if __name__ == "__main__": From f14df7baed762d23cd6fc7d87b122f7e8416aa52 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:17:54 +0100 Subject: [PATCH 11/30] refactoring: renamed tests to fit or operand functionality --- src/test/py/test_logical_operations.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 84bdaaf..75d82e7 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -9,16 +9,16 @@ class calculationsWithRoots(unittest.TestCase): def tearDown(self): pass - def test_disconjunctive_identity_1_and_0_equals_x(self): + def test_disconjunctive_identity_1_or_0_equals_x(self): self.assertEqual(identity_conjunctive(1, "+", 0), 1) - def test_disconjunctive_identity_1_and_1_equals_None(self): + def test_disconjunctive_identity_1_or_1_equals_None(self): self.assertEqual(identity_conjunctive(1, "+", 1), None) - def test_disconjunctive_identity_0_and_1_equals_None(self): + def test_disconjunctive_identity_0_or_1_equals_None(self): self.assertEqual(identity_conjunctive(0, "+", 1), None) - def test_disconjunctive_identity_0_and_0_equals_0(self): + def test_disconjunctive_identity_0_or_0_equals_0(self): self.assertEqual(identity_conjunctive(0, "+", 0), 0) From 13623ba4d382846d06d1dbb7b7896124ac0f4c7f Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 12:27:33 +0100 Subject: [PATCH 12/30] refactoring: renamed function fit functionality --- src/main/py/logical_operations.py | 2 +- src/test/py/test_logical_operations.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 6cbd64b..297746f 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,4 +1,4 @@ -def identity_conjunctive(variable, operator, zero): +def identity_disconjunctive(variable, operator, zero): if zero == 0 and operator == "+": return variable else: diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 75d82e7..051ad51 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -10,16 +10,16 @@ class calculationsWithRoots(unittest.TestCase): pass def test_disconjunctive_identity_1_or_0_equals_x(self): - self.assertEqual(identity_conjunctive(1, "+", 0), 1) + self.assertEqual(identity_disconjunctive(1, "+", 0), 1) def test_disconjunctive_identity_1_or_1_equals_None(self): - self.assertEqual(identity_conjunctive(1, "+", 1), None) + self.assertEqual(identity_disconjunctive(1, "+", 1), None) def test_disconjunctive_identity_0_or_1_equals_None(self): - self.assertEqual(identity_conjunctive(0, "+", 1), None) + self.assertEqual(identity_disconjunctive(0, "+", 1), None) def test_disconjunctive_identity_0_or_0_equals_0(self): - self.assertEqual(identity_conjunctive(0, "+", 0), 0) + self.assertEqual(identity_disconjunctive(0, "+", 0), 0) if __name__ == "__main__": From e5f2a4d8976d22276670e96622898af85f57da69 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:07:04 +0100 Subject: [PATCH 13/30] Added conjunctive function and test --- src/main/py/logical_operations.py | 7 +++++++ src/test/py/test_logical_operations.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 297746f..179714b 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -3,3 +3,10 @@ def identity_disconjunctive(variable, operator, zero): return variable else: return None + + +def identity_conjunctive(variable, operator, zero): + if zero == 0 and operator == "+": + return variable + else: + return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 051ad51..69a9886 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -21,6 +21,9 @@ class calculationsWithRoots(unittest.TestCase): def test_disconjunctive_identity_0_or_0_equals_0(self): self.assertEqual(identity_disconjunctive(0, "+", 0), 0) + def test_disconjunctive_identity_0_or_0_equals_01(self): + self.assertEqual(identity_conjunctive(0, ".", 0), None) + if __name__ == "__main__": unittest.main() From 481e47dd4f581ee75a3a87ef7f262f421e16fe71 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:08:30 +0100 Subject: [PATCH 14/30] refactoring: renamed test case --- src/test/py/test_logical_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 69a9886..e4aa78d 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -21,7 +21,7 @@ class calculationsWithRoots(unittest.TestCase): def test_disconjunctive_identity_0_or_0_equals_0(self): self.assertEqual(identity_disconjunctive(0, "+", 0), 0) - def test_disconjunctive_identity_0_or_0_equals_01(self): + def test_conjunctive_identity_0_and_0_equals_None(self): self.assertEqual(identity_conjunctive(0, ".", 0), None) From 95f2c8c4480bc1a536fc4fcc770ec11c11eeb29a Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:12:59 +0100 Subject: [PATCH 15/30] refactoring: renamed testcase --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index e4aa78d..364d887 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -24,6 +24,9 @@ class calculationsWithRoots(unittest.TestCase): def test_conjunctive_identity_0_and_0_equals_None(self): self.assertEqual(identity_conjunctive(0, ".", 0), None) + def test_conjunctive_identity_1_and_0_equals_None(self): + self.assertEqual(identity_conjunctive(1, ".", 0), None) + if __name__ == "__main__": unittest.main() From 72bc3a2fa7aebe0b1f2b5858723b4df9454c5297 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:21:35 +0100 Subject: [PATCH 16/30] Added another testcase --- src/main/py/logical_operations.py | 2 +- src/test/py/test_logical_operations.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 179714b..3b519aa 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -6,7 +6,7 @@ def identity_disconjunctive(variable, operator, zero): def identity_conjunctive(variable, operator, zero): - if zero == 0 and operator == "+": + if zero == 1 and operator == ".": return variable else: return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 364d887..b52791d 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -27,6 +27,9 @@ class calculationsWithRoots(unittest.TestCase): def test_conjunctive_identity_1_and_0_equals_None(self): self.assertEqual(identity_conjunctive(1, ".", 0), None) + def test_conjunctive_identity_1_and_0_equals_None(self): + self.assertEqual(identity_conjunctive(0, ".", 1), 0) + if __name__ == "__main__": unittest.main() From 8ffb658b99ca63637e3cc2ae593bb562b2e4d2bd Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:22:23 +0100 Subject: [PATCH 17/30] refactoring: renamed testcase --- src/test/py/test_logical_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index b52791d..3f96f90 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -27,7 +27,7 @@ class calculationsWithRoots(unittest.TestCase): def test_conjunctive_identity_1_and_0_equals_None(self): self.assertEqual(identity_conjunctive(1, ".", 0), None) - def test_conjunctive_identity_1_and_0_equals_None(self): + def test_conjunctive_identity_0_and_1_equals_0(self): self.assertEqual(identity_conjunctive(0, ".", 1), 0) From 2d524cba9c230c8962c3fea5fb82c7697fb1ba18 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:23:20 +0100 Subject: [PATCH 18/30] Added another testcase --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 3f96f90..302c8e3 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -30,6 +30,9 @@ class calculationsWithRoots(unittest.TestCase): def test_conjunctive_identity_0_and_1_equals_0(self): self.assertEqual(identity_conjunctive(0, ".", 1), 0) + def test_conjunctive_identity_0_and_1_equals_01(self): + self.assertEqual(identity_conjunctive(1, ".", 1), 1) + if __name__ == "__main__": unittest.main() From cde4279f6458313ab853e0d3d0f7247f7d316829 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:42:28 +0100 Subject: [PATCH 19/30] change to test and function to also allow reverse detection of disconjunctive identiy --- src/main/py/logical_operations.py | 2 ++ src/test/py/test_logical_operations.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 3b519aa..42678a1 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,6 +1,8 @@ def identity_disconjunctive(variable, operator, zero): if zero == 0 and operator == "+": return variable + elif variable == 0 and zero == 1: + return 1 else: return None diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 302c8e3..4099b13 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -16,7 +16,7 @@ class calculationsWithRoots(unittest.TestCase): self.assertEqual(identity_disconjunctive(1, "+", 1), None) def test_disconjunctive_identity_0_or_1_equals_None(self): - self.assertEqual(identity_disconjunctive(0, "+", 1), None) + self.assertEqual(identity_disconjunctive(0, "+", 1), 1) def test_disconjunctive_identity_0_or_0_equals_0(self): self.assertEqual(identity_disconjunctive(0, "+", 0), 0) @@ -30,7 +30,7 @@ class calculationsWithRoots(unittest.TestCase): def test_conjunctive_identity_0_and_1_equals_0(self): self.assertEqual(identity_conjunctive(0, ".", 1), 0) - def test_conjunctive_identity_0_and_1_equals_01(self): + def test_conjunctive_identity_1_and_1_equals_1(self): self.assertEqual(identity_conjunctive(1, ".", 1), 1) From bfc885cbb11773e04634011f96a366b9960cdad3 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 13:51:43 +0100 Subject: [PATCH 20/30] refactoring: optimized identity_disconjunctive --- src/main/py/logical_operations.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 42678a1..3b0ac5a 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,10 +1,10 @@ -def identity_disconjunctive(variable, operator, zero): - if zero == 0 and operator == "+": - return variable - elif variable == 0 and zero == 1: - return 1 - else: +def identity_disconjunctive(first_input, operator, second_input): + if first_input == 1 and second_input == 1: return None + elif first_input == 0 and second_input == 0: + return 0 + else: + return 1 def identity_conjunctive(variable, operator, zero): From 29469d8b8a80fa8128d5a664f2e22c0a5edd4c58 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:01:06 +0100 Subject: [PATCH 21/30] optimized conjunctive function and changed tests to fit --- src/main/py/logical_operations.py | 10 ++++++---- src/test/py/test_logical_operations.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 3b0ac5a..7248048 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -7,8 +7,10 @@ def identity_disconjunctive(first_input, operator, second_input): return 1 -def identity_conjunctive(variable, operator, zero): - if zero == 1 and operator == ".": - return variable - else: +def identity_conjunctive(first_input, operator, second_input): + if first_input == 1 and second_input == 1: + return 1 + elif first_input == 0 and second_input == 0: return None + else: + return 0 diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 4099b13..a8c0994 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -25,7 +25,7 @@ class calculationsWithRoots(unittest.TestCase): self.assertEqual(identity_conjunctive(0, ".", 0), None) def test_conjunctive_identity_1_and_0_equals_None(self): - self.assertEqual(identity_conjunctive(1, ".", 0), None) + self.assertEqual(identity_conjunctive(1, ".", 0), 0) def test_conjunctive_identity_0_and_1_equals_0(self): self.assertEqual(identity_conjunctive(0, ".", 1), 0) From 07188bba77ad78c9a29f28e0f1511db08f584406 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:05:00 +0100 Subject: [PATCH 22/30] Added identify function which decided based on operand --- src/main/py/logical_operations.py | 11 +++++++++-- src/test/py/test_logical_operations.py | 16 ++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 7248048..6b3b78a 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -1,4 +1,4 @@ -def identity_disconjunctive(first_input, operator, second_input): +def identity_disconjunctive(first_input, second_input): if first_input == 1 and second_input == 1: return None elif first_input == 0 and second_input == 0: @@ -7,10 +7,17 @@ def identity_disconjunctive(first_input, operator, second_input): return 1 -def identity_conjunctive(first_input, operator, second_input): +def identity_conjunctive(first_input, second_input): if first_input == 1 and second_input == 1: return 1 elif first_input == 0 and second_input == 0: return None else: return 0 + + +def identity(first_input, operator, second_input): + if operator == "+": + return identity_disconjunctive(first_input, second_input) + else: + return identity_conjunctive(first_input, second_input) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index a8c0994..87f3e17 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -10,28 +10,28 @@ class calculationsWithRoots(unittest.TestCase): pass def test_disconjunctive_identity_1_or_0_equals_x(self): - self.assertEqual(identity_disconjunctive(1, "+", 0), 1) + self.assertEqual(identity(1, "+", 0), 1) def test_disconjunctive_identity_1_or_1_equals_None(self): - self.assertEqual(identity_disconjunctive(1, "+", 1), None) + self.assertEqual(identity(1, "+", 1), None) def test_disconjunctive_identity_0_or_1_equals_None(self): - self.assertEqual(identity_disconjunctive(0, "+", 1), 1) + self.assertEqual(identity(0, "+", 1), 1) def test_disconjunctive_identity_0_or_0_equals_0(self): - self.assertEqual(identity_disconjunctive(0, "+", 0), 0) + self.assertEqual(identity(0, "+", 0), 0) def test_conjunctive_identity_0_and_0_equals_None(self): - self.assertEqual(identity_conjunctive(0, ".", 0), None) + self.assertEqual(identity(0, ".", 0), None) def test_conjunctive_identity_1_and_0_equals_None(self): - self.assertEqual(identity_conjunctive(1, ".", 0), 0) + self.assertEqual(identity(1, ".", 0), 0) def test_conjunctive_identity_0_and_1_equals_0(self): - self.assertEqual(identity_conjunctive(0, ".", 1), 0) + self.assertEqual(identity(0, ".", 1), 0) def test_conjunctive_identity_1_and_1_equals_1(self): - self.assertEqual(identity_conjunctive(1, ".", 1), 1) + self.assertEqual(identity(1, ".", 1), 1) if __name__ == "__main__": From 98cef3cc4039bd6464925781c358aeebb38d1860 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:09:44 +0100 Subject: [PATCH 23/30] refactoring: renamed serveral tests --- src/test/py/test_logical_operations.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 87f3e17..f994cc2 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -9,28 +9,28 @@ class calculationsWithRoots(unittest.TestCase): def tearDown(self): pass - def test_disconjunctive_identity_1_or_0_equals_x(self): + def test_identity_1_or_0_equals_1(self): self.assertEqual(identity(1, "+", 0), 1) - def test_disconjunctive_identity_1_or_1_equals_None(self): + def test_identity_1_or_1_equals_None(self): self.assertEqual(identity(1, "+", 1), None) - def test_disconjunctive_identity_0_or_1_equals_None(self): + def test_identity_0_or_1_equals_1(self): self.assertEqual(identity(0, "+", 1), 1) - def test_disconjunctive_identity_0_or_0_equals_0(self): + def test_identity_0_or_0_equals_0(self): self.assertEqual(identity(0, "+", 0), 0) - def test_conjunctive_identity_0_and_0_equals_None(self): + def test_identity_0_and_0_equals_None(self): self.assertEqual(identity(0, ".", 0), None) - def test_conjunctive_identity_1_and_0_equals_None(self): + def test_identity_1_and_0_equals_0(self): self.assertEqual(identity(1, ".", 0), 0) - def test_conjunctive_identity_0_and_1_equals_0(self): + def test_identity_0_and_1_equals_0(self): self.assertEqual(identity(0, ".", 1), 0) - def test_conjunctive_identity_1_and_1_equals_1(self): + def test_identity_1_and_1_equals_1(self): self.assertEqual(identity(1, ".", 1), 1) From 51229aebd74bd68b6b063469fe838151f3325e9d Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:12:41 +0100 Subject: [PATCH 24/30] Added one_zero functionality and one test for it --- src/main/py/logical_operations.py | 7 +++++++ src/test/py/test_logical_operations.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/main/py/logical_operations.py b/src/main/py/logical_operations.py index 6b3b78a..9edc386 100644 --- a/src/main/py/logical_operations.py +++ b/src/main/py/logical_operations.py @@ -21,3 +21,10 @@ def identity(first_input, operator, second_input): return identity_disconjunctive(first_input, second_input) else: return identity_conjunctive(first_input, second_input) + + +def one_zero(first_input, second_input): + if first_input == 0 and second_input == 0: + return None + else: + return 1 diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index f994cc2..1667909 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -33,6 +33,9 @@ class calculationsWithRoots(unittest.TestCase): def test_identity_1_and_1_equals_1(self): self.assertEqual(identity(1, ".", 1), 1) + def test_one_zero_1_or_1_equals_1(self): + self.assertEqual(one_zero(1, 1), 1) + if __name__ == "__main__": unittest.main() From 2efe0a234377832f8108fddee89d859917976ddc Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:13:46 +0100 Subject: [PATCH 25/30] Added another test --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 1667909..2e60aef 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -36,6 +36,9 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_1_or_1_equals_1(self): self.assertEqual(one_zero(1, 1), 1) + def test_one_zero_1_or_1_equals_11(self): + self.assertEqual(one_zero(0, 1), 1) + if __name__ == "__main__": unittest.main() From 998af39809af30c5e09e9800e57570778601c83b Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:14:15 +0100 Subject: [PATCH 26/30] refactoring: renamed test --- src/test/py/test_logical_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 2e60aef..8c5fd86 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -36,7 +36,7 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_1_or_1_equals_1(self): self.assertEqual(one_zero(1, 1), 1) - def test_one_zero_1_or_1_equals_11(self): + def test_one_zero_0_or_1_equals_1(self): self.assertEqual(one_zero(0, 1), 1) From b649baace0585066ebbf0544f8e773c0079cd5c9 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:14:53 +0100 Subject: [PATCH 27/30] Added another test --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 8c5fd86..d3a8772 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -39,6 +39,9 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_0_or_1_equals_1(self): self.assertEqual(one_zero(0, 1), 1) + def test_one_zero_0_or_1_equals_11(self): + self.assertEqual(one_zero(1, 1), 1) + if __name__ == "__main__": unittest.main() From 60a37956396aee4e51790e96e9306538cea36783 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:17:05 +0100 Subject: [PATCH 28/30] changed test because of duplication --- src/test/py/test_logical_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index d3a8772..968a39d 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -39,8 +39,8 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_0_or_1_equals_1(self): self.assertEqual(one_zero(0, 1), 1) - def test_one_zero_0_or_1_equals_11(self): - self.assertEqual(one_zero(1, 1), 1) + def test_one_zero_1_or_0_equals_1(self): + self.assertEqual(one_zero(1, 0), 1) if __name__ == "__main__": From 5a0dbe4e97e22b63a437950ebcc044c8d8e2e6b9 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:18:13 +0100 Subject: [PATCH 29/30] Added another testcase --- src/test/py/test_logical_operations.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index 968a39d..c64d566 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -42,6 +42,9 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_1_or_0_equals_1(self): self.assertEqual(one_zero(1, 0), 1) + def test_one_zero_1_or_0_equals_11(self): + self.assertEqual(one_zero(0, 0), None) + if __name__ == "__main__": unittest.main() From 98f683ba0ac3abff172e12ce0493d06b9cd1b442 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:19:03 +0100 Subject: [PATCH 30/30] refactoring: renamed testcase --- src/test/py/test_logical_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/py/test_logical_operations.py b/src/test/py/test_logical_operations.py index c64d566..b5c441b 100644 --- a/src/test/py/test_logical_operations.py +++ b/src/test/py/test_logical_operations.py @@ -42,7 +42,7 @@ class calculationsWithRoots(unittest.TestCase): def test_one_zero_1_or_0_equals_1(self): self.assertEqual(one_zero(1, 0), 1) - def test_one_zero_1_or_0_equals_11(self): + def test_one_zero_0_or_0_equals_None(self): self.assertEqual(one_zero(0, 0), None)