Skip to content

Commit bd190ed

Browse files
zvasicekdd
authored and
dd
committed
ENH: add __xor__() to Function
1 parent 09db14f commit bd190ed

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

dd/_abc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@ def __or__(
663663
) -> 'Operator':
664664
r"""Disjunction `self \/ other`."""
665665

666+
def __xor__(
667+
self,
668+
other
669+
) -> 'Operator':
670+
r"""Exclusive or `self + other`."""
671+
666672
def implies(
667673
self,
668674
other

dd/autoref.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,13 @@ def __or__(
812812
) -> _Ref:
813813
return self._apply('or', other)
814814

815+
def __xor__(
816+
self,
817+
other:
818+
_Ref
819+
) -> _Ref:
820+
return self._apply('xor', other)
821+
815822
def implies(
816823
self,
817824
other:

dd/buddy.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,11 @@ cdef class Function:
451451
) -> Function:
452452
r = buddy.bdd_or(self.node, other.node)
453453
return Function(r)
454+
455+
def __xor__(
456+
self,
457+
other:
458+
Function
459+
) -> Function:
460+
r = buddy.bdd_xor(self.node, other.node)
461+
return Function(r)

dd/cudd.pyx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,6 +3126,19 @@ cdef class Function:
31263126
self.manager, self.node, other.node)
31273127
return wrap(self.bdd, r)
31283128

3129+
def __xor__(
3130+
self:
3131+
Function,
3132+
other:
3133+
Function
3134+
) -> Function:
3135+
if self.manager != other.manager:
3136+
raise ValueError(
3137+
'`self.manager != other.manager`')
3138+
r = Cudd_bddXor(
3139+
self.manager, self.node, other.node)
3140+
return wrap(self.bdd, r)
3141+
31293142
def implies(
31303143
self:
31313144
Function,

dd/sylvan.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,3 +1036,15 @@ cdef class Function:
10361036
sy.LACE_ME_WRAP
10371037
r = sy.sylvan_or(self.node, other.node)
10381038
return wrap(self.bdd, r)
1039+
1040+
def __xor__(
1041+
self:
1042+
Function,
1043+
other:
1044+
Function
1045+
) -> Function:
1046+
if self.bdd is not other.bdd:
1047+
raise ValueError((self, other))
1048+
sy.LACE_ME_WRAP
1049+
r = sy.sylvan_xor(self.node, other.node)
1050+
return wrap(self.bdd, r)

0 commit comments

Comments
 (0)