Skip to content

Add erf function - #234

Merged
gdementen merged 15 commits into
liam2:masterfrom
benjello:add_erf_function
Sep 22, 2017
Merged

Add erf function#234
gdementen merged 15 commits into
liam2:masterfrom
benjello:add_erf_function

Conversation

@benjello

@benjello benjello commented May 16, 2017

Copy link
Copy Markdown
Collaborator

This PR adds an erf function using scipy.

@gdementen

Copy link
Copy Markdown
Member

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.

@benjello

Copy link
Copy Markdown
Collaborator Author

@gdementen : what is your favorite implementation ?
I would choose an optional scipy as a standard practice but the function you gave may be faster
and sufficient for liam2 needs.

@gdementen

Copy link
Copy Markdown
Member

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.

@gdementen

Copy link
Copy Markdown
Member

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.

@benjello

Copy link
Copy Markdown
Collaborator Author

There is a link to the implementation in C on this page.

I will use the scipy version.

@benjello

Copy link
Copy Markdown
Collaborator Author

If the implementation suits you I can even write a line in the changelog ;-)

@benjello

Copy link
Copy Markdown
Collaborator Author

@gdementen : any chance this get merged soon ?

@gdementen gdementen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread liam2/exprmisc.py Outdated
def compute(self, context, expr):
if scipy is None:
raise ImportError(
"Scipy was not succesfully imported",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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."

@benjello

benjello commented Sep 22, 2017

Copy link
Copy Markdown
Collaborator Author

Needs to be done:

  • changelog
  • note in documentation

@benjello

Copy link
Copy Markdown
Collaborator Author

@gdementen : rebased, doc and changelog added

@gdementen
gdementen merged commit e8fc667 into liam2:master Sep 22, 2017
@gdementen

Copy link
Copy Markdown
Member

Thanks

@benjello
benjello deleted the add_erf_function branch September 23, 2017 08:17
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.

2 participants