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
Adding the erf
special function to numpy?
#12515
Comments
If it exists on your system, then someone has modified your numpy installation. |
Indeed, the only other mention of
What is the right tracker for such an issue, if there is one? |
@oleksandr-pavlyk ping |
@normalhuman - aside: if your code is meant to be portable, I'd strongly recommend using |
@normalhuman Yes, please use I will make sure to disable |
@oleksandr-pavlyk please consider removing it from the numpy namespace entirely, and moving it into a separate package namespace. Changing the API of a project like this is extremely poor etiquette, because it creates confusion among users (like we saw here), and sets us up for more breakage later. (What are you going to do if numpy does add an |
@oleksandr-pavlyk For context, |
@njsmith Would it be OK to keep |
Personally, I think Let me ping @rgommers to see what he thinks about moving/duplicating |
The line that we currently have drawn for special functions in the Disclosure: I work for Enthought, which is also in the business of distributing optimized builds of numpy, so please consider this next recommendation in that light. However, I promise that it is offered in good faith, only informed by our past mistakes when we overzealously added additional functionality to numpy and had to revert them because they caused problems. @oleksandr-pavlyk Please don't add stuff to |
I agree with @rkern's thoughts about scope. In addition, in this particular case it doesn't seem like effort well spent, since there'll not be many use cases where
this I'm not sure about - I know SymPy and other libs do dig in there, but |
I don't think that's correct... do you mean C89? Traditionally we've supported non-C99 compilers (like old MSVC), and C99 does have |
@rkern - agreed with your point that we should support what a particular standard provides. Our documentation indeed seems to suggest we support C99, which, as @njsmith notes includes p.s. Nevertheless, agreed with all here that one should not insert any such functions in any of the numpy namespaces without there being a generic implementation; astropy does inspect |
Sorry, our policy has more or less been "if it's in C99, we'll let it in if someone wants to do the work; otherwise, keep it in Our support for C99 compilers is neither here nor there. We don't rely on the implementation being provided by the C99 compiler. This was just an arbitrary, objective policy for deciding which special functions should get into |
Basically, the policy takes a negative form: "if a special function is not in C99, it doesn't go into |
Adding Of course it would slow down development and be more involved. But I think it should be reasonable if Intel puts in special code that will be used instead of the default one when compiling with the hard dependency of MKL. Similar to SIMD inner loops that I think we have to replace others when available. That is assuming that it does not add a huge amount of new complexity probably. |
real erf is very simple, complex is much more complex to get right (the impl in scipy is in c++ which makes copypasting it to numpy harder)
…On December 28, 2018 1:47:16 PM UTC, Sebastian Berg ***@***.***> wrote:
Adding `erf` sounds fine, although I am not 100% sure that we should
add it if we do not (or cannot) add the complex versions as well
(assuming there is not really a precedence for that already).
Of course it would slow down development and be more involved. But I
think it should be reasonable if Intel puts in special code that will
be used instead of the default one when compiling with the hard
dependency of MKL. Similar to SIMD inner loops that I think we have to
replace others when available. That is assuming that it does not add a
huge amount of new complexity probably.
|
True. What we have done in the past for such functions is copy from FreeBSD, much of whose implementation seems to have come from Silicon Graphics back in the day. I don't know if that would work here... |
I think just having real |
erf
special function to numpy?
EDIT: the original issue here was resolved a long time ago, Intel removed their
erf
addition which wasn't in numpy. Issue retitled to reflect the discussion about addingnp.erf
When
np.erf
is given a complex number, it returns the number itself instead of the value of the error function. For example,scipy.special.erf(1+2j)
returns(-0.5366435657785664-5.0491437034470374j)
butnp.erf
returns(1+2j)
itself.Reproducing code example:
Error message:
None, but the return value is wrong for complex arguments. It is simply the argument itself. If complex inputs are not supported, an error should be thrown instead.
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: