Quansight-Labs / unumpy

A backend-dispatchable version of NumPy.
https://unumpy.uarray.org/
BSD 3-Clause "New" or "Revised" License
19 stars 10 forks source link

Add more core NumPy Functions #6

Closed hameerabbasi closed 5 years ago

hameerabbasi commented 5 years ago
rgommers commented 5 years ago

Maybe errstate & co, the set routines (unique in particular) and the sort routines? and np.pad?

hameerabbasi commented 5 years ago

Updated the list. 😄

hameerabbasi commented 5 years ago

Question: Do we want to provide a default implementation?

rgommers commented 5 years ago

Question: Do we want to provide a default implementation?

Depends on what that means I guess. I think it may be fine if

import unumpy as np
np.arange(5)

gives an error. However I think if you import one backend it should work with explicitly having to set the backend.

import unumpy as np
from unumpy.backends import XndBackend  # or some such line
np.arange(5)

Or do you mean the order in which backends are chosen?

hameerabbasi commented 5 years ago

Ah, I mean (to be specific): Do we want a default implementation for MultiMethods in terms of others, if it is reasonably efficient?

rgommers commented 5 years ago

That doesn't make it much clearer for me ..... Can you give a concrete example?

hameerabbasi commented 5 years ago

So, I currently dispatch sum to add.reduce with the appropriate arguments. Do we want to do something similar with some of these other functions?

rgommers commented 5 years ago

Hmm, I'd guess not. The signatures in numpy for those two things don't even match, and other libraries may not match numpy. Why not leave that up to the backend?

hameerabbasi commented 5 years ago

To make it easier for the backend... And make gradual implementation easier while still having the option for a more complex or efficient one.

rgommers commented 5 years ago

How many functions can this be done for? sum, min, max, what else?

hameerabbasi commented 5 years ago

A lot of them, actually... nan-reductions most of the time, usual reduction functions, stack/concatenate/block, argwhere/where/nonzero, etc.

To be clear, the backend can still override them. There will be a big bold disclaimer saying these can change.

rgommers commented 5 years ago

Hmm yeah okay, I can see how that saves doing the exact same thing in multiple backends. So yes with a clear statement in the docs that this is done, why not?

hameerabbasi commented 5 years ago

Broadcasting and concat/stack done.

hameerabbasi commented 5 years ago

Searching and pad done!

hameerabbasi commented 5 years ago

Closed this since everything here is done.