diff --git a/btypes_primitives/src/main/python/btypes/BRelation.py b/btypes_primitives/src/main/python/btypes/BRelation.py index 9483653189177a243d6a35d48fcb552f8e89f7f4..42ec09f31d5a059e9f7ff2b45253a2ffd4bf841e 100644 --- a/btypes_primitives/src/main/python/btypes/BRelation.py +++ b/btypes_primitives/src/main/python/btypes/BRelation.py @@ -165,7 +165,7 @@ class BRelation: def relationImage(self, domain: 'BSet') -> 'BSet': result_set = set() for domain_element in domain: - this_range_set = self.map[domain_element] + this_range_set = self.map.get(domain_element, None) if this_range_set is None: continue result_set = result_set.union(this_range_set) diff --git a/btypes_primitives/src/main/python_magicstack_immutable/btypes/BBoolean.py b/btypes_primitives/src/main/python_magicstack_immutable/btypes/BBoolean.py index cb95d7e65cbaf1b495ffcc5f8fa053b9b7684ff8..bbb1bfef13df075ff713a51ef1641610698d0180 100644 --- a/btypes_primitives/src/main/python_magicstack_immutable/btypes/BBoolean.py +++ b/btypes_primitives/src/main/python_magicstack_immutable/btypes/BBoolean.py @@ -4,6 +4,11 @@ class BBoolean: self.__value = value elif type(value) is str: self.__value = str(value).lower() == "true" + elif type(value) is BBoolean: + self.__value = value.__value + + def __bool__(self) -> 'bool': + return self.__value def __and__(self, other: 'BBoolean') -> 'BBoolean': return BBoolean(self.__value and other.__value) @@ -32,29 +37,29 @@ class BBoolean: def __ne__(self, other: 'BBoolean') -> 'BBoolean': return BBoolean(self.__value != other.__value) - def _and(self, other: 'BBoolean') -> 'BBoolean': + def _and(self, other: 'BBoolean') -> 'BBoolean': return self.__and__(other) - def _or(self, other: 'BBoolean') -> 'BBoolean': + def _or(self, other: 'BBoolean') -> 'BBoolean': return self.__or__(other) def _not(self) -> 'BBoolean': return BBoolean(not self.__value) - def implies(self, other: 'BBoolean') -> 'BBoolean': + def implies(self, other: 'BBoolean') -> 'BBoolean': return self._not()._or(other) - def equivalent(self, other: 'BBoolean') -> 'BBoolean': + def equivalent(self, other: 'BBoolean') -> 'BBoolean': return self.implies(other)._and(other.implies(self)) - def equal(self, other: 'BBoolean') -> 'BBoolean': + def equal(self, other: 'BBoolean') -> 'BBoolean': return self.__eq__(other) - def unequal(self, other: 'BBoolean') -> 'BBoolean': + def unequal(self, other: 'BBoolean') -> 'BBoolean': return self.__ne__(other) def booleanValue(self) -> 'bool': return self.__value def __hash__(self): - return hash(self.__value) \ No newline at end of file + return hash(self.__value) diff --git a/btypes_primitives/src/main/python_pyrsistant_immutable/btypes/BBoolean.py b/btypes_primitives/src/main/python_pyrsistant_immutable/btypes/BBoolean.py index cb95d7e65cbaf1b495ffcc5f8fa053b9b7684ff8..b30bc48c97b8fe87a32dcaa5a44544576e8ded92 100644 --- a/btypes_primitives/src/main/python_pyrsistant_immutable/btypes/BBoolean.py +++ b/btypes_primitives/src/main/python_pyrsistant_immutable/btypes/BBoolean.py @@ -4,6 +4,8 @@ class BBoolean: self.__value = value elif type(value) is str: self.__value = str(value).lower() == "true" + elif type(value) is BBoolean: + self.__value = value.__value def __and__(self, other: 'BBoolean') -> 'BBoolean': return BBoolean(self.__value and other.__value) @@ -57,4 +59,4 @@ class BBoolean: return self.__value def __hash__(self): - return hash(self.__value) \ No newline at end of file + return hash(self.__value)