Skip to content
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

ufunc data seems to be missing #144

Open
rgommers opened this issue Feb 4, 2021 · 3 comments
Open

ufunc data seems to be missing #144

rgommers opened this issue Feb 4, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@rgommers
Copy link
Member

rgommers commented Feb 4, 2021

I was looking for def sin and other such functions in typing/numpy.py, and they're missing completely. It's unclear why.

The actual question I was trying to figure out is: how often is the dtype keyword used for unary ufuncs. I thought the data I needed would be here, but it looks like it's not.

@rgommers rgommers added the bug Something isn't working label Feb 4, 2021
@kgryte
Copy link
Contributor

kgryte commented Feb 4, 2021

Does this have to do with the Python-C bridge? Meaning, I am not sure that the tooling currently picks up C-level argument handling, which could be applicable for ufuncs.

@rgommers
Copy link
Member Author

rgommers commented Feb 4, 2021

Ah yes, that's it (unfortunately). Pretty much all functions that are not ufuncs have a thin Python shim and will be picked up, ufuncs aren't.

@rgommers rgommers added enhancement New feature or request and removed bug Something isn't working labels Feb 4, 2021
@saulshanabrook
Copy link
Contributor

The ufunc data is available, see in the file you referenced:
 

# usage.dask: 58
# usage.hvplot: 1
# usage.koalas: 5
# usage.matplotlib: 127
# usage.networkx: 5
# usage.orange3: 6
# usage.pandas: 34
# usage.prophet: 2
# usage.scipy: 296
# usage.seaborn: 1
# usage.skimage: 51
# usage.sklearn: 32
# usage.statsmodels: 47
# usage.xarray: 30
sin: numpy.ufunc

Since ufuncs are a custom object, not just a function, we record them as such. If you then look at the same file, you will see a class ufunc which has the overloads for all the calls:

class ufunc:

    # usage.dask: 1
    __module__: ClassVar[object]

    @overload
    def __call__(self, _0: pandas.core.frame.DataFrame, _1: int, /):
        """
        usage.dask: 85
        usage.koalas: 24
        """
        ...

    @overload
    def __call__(self, _0: int, _1: int, /):
        """
        usage.dask: 1
        usage.koalas: 1
        usage.matplotlib: 2
        usage.scipy: 135
        usage.skimage: 1
        usage.sklearn: 3
        usage.statsmodels: 10
        usage.xarray: 4
        """
        ...

So it is currently showing the number of times each ufunc is retrieved from the ufunc module (the first stats) and then also how ufuncs are called generally (the second stats).

We could also show the product of these, showing per ufunc instance how it's called.

Currently, ufuncs all show up as defined in the numpy module, because it's hard to find where they were defined (#70)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants