Browse Source

optimized conjunctive function and changed tests to fit

remotes/origin/feature/feature-logical-operations
fdai7783 11 months ago
parent
commit
29469d8b8a
  1. 10
      src/main/py/logical_operations.py
  2. 2
      src/test/py/test_logical_operations.py

10
src/main/py/logical_operations.py

@ -7,8 +7,10 @@ def identity_disconjunctive(first_input, operator, second_input):
return 1 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 return None
else:
return 0

2
src/test/py/test_logical_operations.py

@ -25,7 +25,7 @@ class calculationsWithRoots(unittest.TestCase):
self.assertEqual(identity_conjunctive(0, ".", 0), None) self.assertEqual(identity_conjunctive(0, ".", 0), None)
def test_conjunctive_identity_1_and_0_equals_None(self): 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): def test_conjunctive_identity_0_and_1_equals_0(self):
self.assertEqual(identity_conjunctive(0, ".", 1), 0) self.assertEqual(identity_conjunctive(0, ".", 1), 0)

Loading…
Cancel
Save