Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expose inner1d and other generalized universal functions from numpy.core.umath_tests #16983

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

Open
vyacheslav-zhukov opened this issue Jul 31, 2020 · 7 comments

Comments

@vyacheslav-zhukov
Copy link

In reply to:

... If someone wants inner1d exposed, please open a new issue for that. I will close this one. ...

Originally posted by @seberg in #13568 (comment)

Please expose inner1d and other generalized universal functions from numpy.core.umath_tests.

Except matrix_multiply has been re-implemented as matmul in NumPy 1.10. Perhaps move the umath_tests module next to matmul module under a new name?

Originally, these functions were placed in umath_tests module for no particular reason. They are not test functions by any means, in fact, they are very useful functions sometimes. They make corresponding operations on "stacked arrays" faster and/or using less memory.

It seems like gufuncs have been gradually gaining acceptance. numpy.linalg was upgraded to gufuncs in NumPy1.8. And #11492 "Use gufuncs for partition, sort, etc., so they can be overridden with __array_ufunc__" is on the road map.

Why remove several useful gufuncs? Perhaps even improve inner1d to use BLAS, like matmul?

@eric-wieser
Copy link
Member

eric-wieser commented Jul 31, 2020

Originally, these functions were placed in umath_tests module for no particular reason. They are not test functions by any means

They were put there for a very particular reason - they were a simple way to test the internals of ufuncs, and that third party modules could define their own. They were definitely intended as functions to be used internally in numpy's own tests.

Having said that, you're right that an inner1d gufunc may be a useful addition to the public API. It would be helpful if you could list all the functions that you would like to see re-added publicly.

@vyacheslav-zhukov
Copy link
Author

The generalized ufuncs were external contributions to NumPy. See:

The gufuncs were native in Perl Data Language and we wanted to add them to NumPy. It was a difficult process, with NumPy developers being reluctant about it. As a compromise, obviously non-test function ended up in a test module.

For the list of functions, I think all but matrix_multiply are good: inner1d, innerwt, euclidean_pdist, cross1d, and even cumsum (as a gufunc).

@eric-wieser
Copy link
Member

Thanks for digging up the history!

@eric-wieser
Copy link
Member

It was a difficult process, with NumPy developers being reluctant about it.

It sounds like this was before my time, and presumably before numpy moved to GitHub. Are those conversations lost to time?

@vyacheslav-zhukov
Copy link
Author

I was not a first party to those conversations. But there's some memory left, #1485 for example. And then there are threads in the mail archives. The long one is https://www.mail-archive.com/[email protected]/msg11837.html

@charris
Copy link
Member

charris commented Aug 1, 2020

IIRC, Travis did the merge of the infrastructure, looks like @stefanv wrote the testing implementations (2008). IIRC, the actual implementations for linalg, came in later from ContinuumIO (Anaconda) (2012-13), because some of their customers wanted them. I don't recall much list discussion when they first appeared.

@seberg
Copy link
Member

seberg commented Aug 3, 2020

Some of these could probably go into np.linalg (e.g. as Eric said, inner1d, since it cannot be reached through matmul, OTOH, it should probably use a similar technique to go through BLAS, which the current version does not). The other option is to use this as an excuse to make an additional (g)ufuncs package in the numpy repo to house a few of these, which may also make it easier to overlook potential holes (i.e. I do not know whether those ufuncs are defined for all dtypes, such as objects).

euclidian_pdist sounds like something that scipy already has for example.

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

No branches or pull requests

4 participants