-
Notifications
You must be signed in to change notification settings - Fork 11
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
Numerical Integrator added to SRC along with the __init__() file #391
Conversation
gusto/numerical_integrator.py
Outdated
class NumericalIntegral(object): | ||
""" | ||
A class for numerically evaluating and tabulating some 1D integral. | ||
:arg lower_bound: lower bound of integral |
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.
These docstrings don't match the style now used through the rest of Gusto -- would you be able to be able to update this?
gusto/numerical_integrator.py
Outdated
def evaluate_at(self, points): | ||
""" | ||
Evaluates the integral at some point using linear interpolation. | ||
:arg points: the point value, or array of point values to evaluate |
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.
Same with the docstrings here
gusto/numerical_integrator.py
Outdated
def tabulate(self, expression): | ||
""" | ||
Tabulate some integral expression using Simpson's rule. | ||
:arg expression: a function representing the integrand to be evaluated. |
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.
Same with these docstrings
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 doing this! The main thing that we need is a unit-test for this, just to check some analytic integral
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.
Looking really good and it's very nearly ready to go on. Just a few tiny things left to sort. Thanks for doing this!
answer = 9 | ||
elif integrand_name == "sine": | ||
integrand = sine | ||
upperbound = 2*pi |
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.
Could you integrate this to pi
instead of 2*pi
so that the answer isn't 0? Just in case the whole thing is doing nothing we would get 0 as the answer so this makes the test extra-safe
Evaluates the integral at some point using linear interpolation. | ||
Args: | ||
points (float or iter) the point value, or array of point values to | ||
evaluate the integral at. |
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.
This docstring should also have a Returns:
statement, as the function routines something
gusto/__init__.py
Outdated
@@ -21,3 +21,4 @@ | |||
from gusto.timeloop import * # noqa | |||
from gusto.transport_methods import * # noqa | |||
from gusto.wrappers import * # noqa | |||
from gusto.numerical_integrator import * # noqa |
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.
These imports are ordered alphabetically so could you put it in its correct place?
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.
Looks great now, thanks for taking this on!
Added a numerical integrator to Gusto SRC along with a corrosponding initialisation call into the innit() file