Skip to content

ENH: Report the correct function name for incorrect arguments #21647

@seberg

Description

@seberg

It would be nice if we could fix the fact that the __array_function__ implementation reports a bad name for its TypeErrors:

import numpy as np
np.histogram(asdf=3)

gives:

TypeError: _histogram_dispatcher() got an unexpected keyword argument 'asdf'

But it would be much nicer if that read histogram() got an unexpected keyword argument 'asdf'.

We should probably just override the name of the dispatcher functions? That could be done in the array-function decorators. Alternatively, it might just work to just rename the dispatchers themselves, but I am not 100% sure if all of them are defined directly "above" the functions that they belong to (so that this should work pretty easily).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions