From 29469d8b8a80fa8128d5a664f2e22c0a5edd4c58 Mon Sep 17 00:00:00 2001 From: fdai7783 Date: Sun, 4 Feb 2024 14:01:06 +0100 Subject: [PATCH] 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)