Skip to content

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

Merged
merged 5 commits into from
Jun 10, 2020
Merged

Evaluate #76

merged 5 commits into from
Jun 10, 2020

Conversation

gemerden
Copy link
Contributor

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))

gemerden added 4 commits July 14, 2017 11:26
__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.
Copy link
Collaborator

@pombredanne pombredanne left a 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?

@gemerden
Copy link
Contributor Author

i split the import and made reduce to be imported under python 3.

@gemerden
Copy link
Contributor Author

Any chance of having this PR merged into master?

@pombredanne
Copy link
Collaborator

@gemerden sure! let me review and merge. Thanks for updating and ensuring the tests pass.

@pombredanne
Copy link
Collaborator

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!

@pombredanne
Copy link
Collaborator

@gemerden I worked on rebasing #72 on the latest master, so there is some progress, at last. Do you need support for Python2 for this or only Python3?

@Kronuz
Copy link
Collaborator

Kronuz commented Apr 5, 2018

Please do keep support for Python 2, I need that.

@pombredanne
Copy link
Collaborator

@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.
Alternatively we could consider the opposite and applying some automated transformation script to the Python2 sources to make then Python3 and transpilable to JS? Not sure what is the best way.

@gemerden
Copy link
Contributor Author

gemerden commented Apr 5, 2018

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.

@gemerden
Copy link
Contributor Author

Any progress on this PR, it seems such a logical thing to add.

@gemerden
Copy link
Contributor Author

@pombredanne any progress on this, python3 only would be fine for me.

@pombredanne
Copy link
Collaborator

@gemerden sorry for dropping the ball here! do you mind rebasing on the latest develop branch?

@pombredanne
Copy link
Collaborator

@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

@gemerden
Copy link
Contributor Author

gemerden commented Jun 10, 2020

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.

@pombredanne pombredanne merged commit 626200a into bastikr:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants