-
Notifications
You must be signed in to change notification settings - Fork 35
Evaluate #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluate #76
Conversation
__call__methods are added to Symbol, NOT, AND, OR. In short: __call__methods are recursively called on NOT, AND, OR classes, following the logic tree via self.args. When a Symbol instance is found, the corrsponding value (e.g. True/False) is looked up in the kwargs argument and returned to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! the tests seem to fail on Python3 with NameError: name 'reduce' is not defined
... do you mind having a look at these?
i split the import and made |
Any chance of having this PR merged into master? |
@gemerden sure! let me review and merge. Thanks for updating and ensuring the tests pass. |
Looking all good to me. I will merge but I need to decide on a merging strategy with regards to the changes by @all3fox first! Thank you for your patience! |
Please do keep support for Python 2, I need that. |
@Kronuz So do I for sure. So we will keep this alright: The only thing is that these will be two different branches in a near future and will have a few but minor differences (mostly because the transpilation to JS works only on Python3). And I will keep backporting to the Python2 branch as needed for the foreseeable future. |
For now i have used boolean.py in a slightly different manner, so i won't be using this directly for now. Therefore do as you like. |
Any progress on this PR, it seems such a logical thing to add. |
@pombredanne any progress on this, python3 only would be fine for me. |
@gemerden sorry for dropping the ball here! do you mind rebasing on the latest develop branch? |
@gemerden I would like to get this in the next release soon enough ... Tell me if you can rebase, otherwise I will try to handle it |
Good news, also i have never used rebase (and i have no idea what has been changed on master or develop, haven’t looked at the repo since i made the PR), so if you could do it that would be great. I will help as needed ofcourse. |
adds ability to evaluate boolean expressions, as in:
algebra = BooleanAlgebra()
exp = algebra.parse("!(a|b&(a|!c))")
a, b, c = True, False, True
assert exp(a=a, b=b, c=c) == not(a or b and (a or not c))