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

New math operations #449

Merged
merged 3 commits into from Dec 1, 2016
Merged

Conversation

co-sty
Copy link
Contributor

@co-sty co-sty commented Dec 1, 2016

The changes are:

  • added support for mathematical constants and some numpy functions (closes Additional operations for the Math logic adapter #320)
  • some refactoring of the chunk processing (nested if/else statements)
  • separating words using a operators rather than spaces (allowing strings such as "log(3+4)" to be processed, instead of just "log ( 3 + 4 ) ")

I hope this is in keeping with coding standards of the project, especially the addition of a class attribute (functions in MathematicalEvaluation). Also, there could be more math functions and constants.

Copy link
Owner

@gunthercox gunthercox left a comment

Choose a reason for hiding this comment

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

These changes look fantastic. Thank you!

string += str(is_chunk_integer) + ' '
for chunk in chunks:
for checker in ['is_integer', 'is_float', 'is_operator', 'is_constant', 'is_function']:
result = getattr(self, checker)(chunk)
Copy link
Owner

Choose a reason for hiding this comment

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

This is a really nice revision to the previous setup.

self.assertEqual(response.text, '3.141693 + 2.718281 = 5.859974')

def test_math_functions(self):
statement = Statement('What is log ( 5 + 6 ) * sqrt ( 12 ) ?')
Copy link
Owner

Choose a reason for hiding this comment

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

Thank you for including tests!

@gunthercox gunthercox merged commit 71c5300 into gunthercox:master Dec 1, 2016
@co-sty
Copy link
Contributor Author

co-sty commented Dec 1, 2016

Thanks a lot for your enthusiasm!

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.

Additional operations for the Math logic adapter
2 participants