Skip to content
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

Implemented Expression Interface #5

Merged
merged 7 commits into from
Jun 9, 2022

Conversation

hsiang-wu
Copy link
Contributor

In addition to the project plan, I also implemented a replace() method, which is similar to a common API of both Z3 and SymPy.

I did not choose to implement Variable, Constant and FunctionApplication as abstract because their attributes and properties can be shared among subclasses. In that case, BasicVariable/Constant/FunctionApplication are just empty vessels.

I also included a test pattern_match_test for Python's new pattern matching feature which I'm not very familiar with. I found its official doc a little ambiguous so I played with it a bit.

Pattern matching is used in the implementation of __eq__(). It can also be useful when implementing interpreter, etc.

…t-in functions type; added a test for pattern matching
Copy link
Owner

@rodrigodesalvobraz rodrigodesalvobraz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff! I think this will require a few more changes but overall it's in a good shape!

neuralpp/symbolic/expression.py Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
neuralpp/symbolic/expression.py Outdated Show resolved Hide resolved
…ation in the project plan's

comments; borrowed from strech goal the new_* function as they're handy to implement set()
and replace() on abstract Expression; implemented __init__() of Basic* with what was in the interface.
@hsiang-wu
Copy link
Contributor Author

Removed all __init__() in Expression to make it indeed virtual, as @rodrigodesalvobraz pointed out in the comments of project plan.

neuralpp/symbolic/function.py Outdated Show resolved Hide resolved
neuralpp/test/quick_tests/symoblic/expression_test.py Outdated Show resolved Hide resolved
@rodrigodesalvobraz rodrigodesalvobraz merged commit 97d7893 into rodrigodesalvobraz:main Jun 9, 2022
@hsiang-wu hsiang-wu deleted the expression branch June 14, 2022 17:55
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.

4 participants