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

Skip to content

DOC: __array_finalize__ arguments inconsistent between docs and interface #20717

Closed
@jcreinhold

Description

@jcreinhold

Issue with current documentation:

The interface for the __array_finalize__ method in the ndarray class for numpy v1.22.0 has no arguments:

def __array_finalize__(self) -> None: ...

However, the documentation for subclassing an ndarray states that __array_finalize__ has one argument called obj.

I have code that subclasses ndarray following the documentation (so it takes the argument called obj), and it appears to work with numpy v1.22.0; however, it doesn't pass type checking with mypy due to it having a different type signature than the superclass.

Note that subclasses of ndarray in the interface (e.g., recarray) use the single argument in the __array_finalize__ method.

Which is correct? Or is something more complicated going on under the hood that makes them both correct?

I checked the devdocs and this issue is present in them as well.

Idea or request for content:

Fix the ndarray interface to have one argument or add a disclaimer to the subclassing documentation if something more complicated is going on under the hood.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions