Last active
October 18, 2019 00:15
-
-
Save cipherboy/31afa9551cb38e78ae8d63b0ad379c3d to your computer and use it in GitHub Desktop.
MyPy Wat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmsh/var.py:222: error: Argument 1 to "v_not" has incompatible type "Union[bool, Variable]"; expected "Variable" | |
cmsh/var.py:276: error: Argument 1 to "v_not" has incompatible type "Union[bool, Variable]"; expected "Variable" | |
cmsh/var.py:318: error: Argument 1 to "v_not" has incompatible type "Union[bool, Variable]"; expected "Variable" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def b_nand(left: Union[bool, Variable], right: Union[bool, Variable]) -> Union[bool, Variable]: | |
""" | |
Computes the binary NAND between left and right operands. | |
Args: | |
left (bool or Variable): left operand. | |
right (bool or Variable): right operand. | |
Returns: | |
bool or Variable: the result of the operation. | |
""" | |
if isinstance(left, bool) and isinstance(right, bool): | |
return not (left and right) | |
if isinstance(left, bool): | |
if not left: | |
return True | |
return v_not(right) | |
if isinstance(right, bool): | |
if not right: | |
return True | |
return v_not(left) | |
return v_nand(left, right) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment