Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TYP: broadnp.linalg return types #30405

Open
Assignees
jorenham
@autra

Description

@autra

Describe the issue:

Followup of#27957 because the issue is not fixed fornumpy.linalg.inv.

numpy.linalg.inv apparently loses some typing information.

The following snippet is a test case demonstrating the issue. In my real code, I tried to pass inv_test to a function that only acceptsNDArray[np.float64]. I'd expect an inversion to keep the same float size in type.

Reproduce the code example:

importnumpyasnpimportnumpy.typingasnpttest:npt.NDArray[np.float64]=np.array([1.0,2.0,3.0],dtype=np.float64)inv_test:npt.NDArray[np.float64]=np.linalg.inv(test)

Error message:

test.py:5: error: Incompatible typesin assignment (expression hastype"ndarray[tuple[Any, ...], dtype[floating[Any]]]", variable hastype"ndarray[tuple[Any, ...], dtype[float64]]")  [assignment]Found 1 errorin 1 file (checked 1source file)

Python and NumPy Versions:

numpy: 2.3.5
python: 3.14.0 (main, Oct 7 2025, 09:34:52) [GCC 14.3.0]

Type-checker version and settings:

❯ mypy --versionmypy 1.19.0 (compiled: yes)

I usedmypy test.py andmypy --local-partial-types --allow-redefinition-new test.py, same result.

Additional typing packages.

typing_extensions: 4.15.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp