Add erf function #234
Add erf function #234
Conversation
I do not want to depend on scipy, so the function must be either optional (only available if scipy is installed) or computed via an expression like shown at http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python, if the later approach gives sufficient precision. |
@gdementen : what is your favorite implementation ? |
I have no idea if what I linked to is precise enough. I am not really qualified to tell. I would accept either, so do what you prefer/think is best. The second option might be faster indeed thanks to numexpr/multi-threading, but that would need to be tested. |
I cannot find to code of the erf function in scipy, it seems like it links to a C implementation from some other lib, so it is unlikely we will get any faster, at least with a single thread. |
There is a link to the implementation in C on this page. I will use the scipy version. |
If the implementation suits you I can even write a line in the changelog ;-) |
…d with an invalid id
@gdementen : any chance this get merged soon ? |
Sorry for the awful delay. It completely went off my radar. If you could add a note in the documentation & changelog, that would be great. |
def compute(self, context, expr): | ||
if scipy is None: | ||
raise ImportError( | ||
"Scipy was not succesfully imported", |
gdementen
Sep 22, 2017
Member
I would like a better message for people trying to use it without scipy installed. Something like:
"Failed to import scipy, which is required for erf(). Please make sure scipy is installed and working."
I would like a better message for people trying to use it without scipy installed. Something like:
"Failed to import scipy, which is required for erf(). Please make sure scipy is installed and working."
Needs to be done:
|
@gdementen : rebased, doc and changelog added |
Thanks |
This PR adds an erf function using scipy.