-
-
Notifications
You must be signed in to change notification settings - Fork 553
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
#1183 added erf and erfc #1184
#1183 added erf and erfc #1184
Conversation
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 good, just needs CHANGELOG :) and you can remove Erfc
pybamm/expression_tree/functions.py
Outdated
|
||
def _function_diff(self, children, idx): | ||
""" See :meth:`pybamm.Function._function_diff()`. """ | ||
return -2 / np.sqrt(np.pi) * Exponential(-children[0] ** 2) |
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.
I don't think we need this class, given how you defined erfc
Not sure why does the test not pass in MacOs. Maybe the values are slightly different and that's why it crashes. Can someone with a Mac check if that's the case? |
Yeah it seems like casadi and numpy have different implementations of erf on Mac:
|
Opened casadi/casadi#2672 |
Should I define an |
If you can figure out how :) I briefly tried but couldn't. It's still weird that casadi gives different values on mac and windows/linux though |
CasADi people say it's not something they can fix. So we should figure out how to implement assertCasadiAlmostEqual |
(casadi.fabs(casadi.evalf(a) - casadi.evalf(b)) < tol).is_one() | ||
) | ||
else: | ||
self.assertTrue((casadi.fabs(a - b) < tol).is_one()) |
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.
nicely done!
Description
Added Erf and Erfc functions
Fixes #1183
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ flake8
$ python run-tests.py --unit
$ cd docs
and then$ make clean; make html
You can run all three at once, using
$ python run-tests.py --quick
.Further checks: