Skip to content

DEP: Deprecate numpy.linalg.lapack_lite module#32015

Open
prathamhole14 wants to merge 4 commits into
numpy:mainfrom
prathamhole14:dep_lapack_lite-
Open

DEP: Deprecate numpy.linalg.lapack_lite module#32015
prathamhole14 wants to merge 4 commits into
numpy:mainfrom
prathamhole14:dep_lapack_lite-

Conversation

@prathamhole14

Copy link
Copy Markdown
Contributor

PR summary

As titled, based on: #31928 (comment)

Note:
If a user simply import numpy.linalg.lapack_lite it will not give warning, it will warn only if used in test (run via pytest) or with -W flag with python3/python.

CC: @seberg @mattip

AI Disclosure

To write release note - it LGTM but someone please check it again. And to find the best way to write test for module dep.

@jorenham jorenham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if we could slap some @typing_extensions.deprecated onto the functions in https://github.com/numpy/numpy/blob/cda64f0cf4584aa9e735d46ba27874296501333a/numpy/linalg/lapack_lite.pyii . That way static type-checkers will warn you if you use it at type-check-time.

@prathamhole14

prathamhole14 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for pointing that out I was unaware of @typing_extensions.deprecated.

@jorenham jorenham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stub changes look good; thanks 👍

Comment thread numpy/linalg/lapack_lite.pyi Outdated
info: int, # out
) -> _DORGQR: ...

@deprecated("The numpy.linalg.lapack_lite module is deprecated and will be removed in a future release. It is an internal implementation detail of numpy.linalg.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these deprecation warnings suggest what users should do instead?

See https://github.com/search?q=%22import+lapack_lite%22&type=code for a large number of real-world users of the lapack_lite module. Do any of the uses in my search hit these new warnings? What should they do when they see the warning.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you filter out all of numpy's own sources in site-packages and stuff, then it's really not that much (152 hits):

https://github.com/search?q=%22import+lapack_lite%22++NOT+is%3Aarchived+NOT+path%3A%2Fnumpy%5C%2Flinalg%5C%2F%2F&type=code

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even there a lot seem just the numpy source. It's a bit unclear I looked at a few:

  • 2 were importing scipy, so I think they can use the scipy lapack exposure if they really want the "low-level" feel?
  • one seemed to pull it in to load math so's but loading numpy.linalg should do that, but not sure this one is weird...
  • one actually patched numpy.linalg.lapack_lite rather than importing it.
  • One was some super outdated chunk of code, I wouldn't worry about.

Could scan more, but I would think it's fine dozens of users and it seems unlikely many don't have better alternatives (i.e. scipy).

That said, pointing to scipy for it's low-level lapack exposure probably makes sense?

@mattip

mattip commented Jul 16, 2026

Copy link
Copy Markdown
Member

If there are people using this module for real code, then the whole premise of this issue and PR are less correct ( i.e. wrong) and we shouldn’t deprecate it.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecating LGTM, this isn't meant to be public. One test should be removed before merging.

Comment thread numpy/linalg/tests/test_deprecations.py Outdated

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked an AI model to search for open-source uses of this module and it found two cases that aren't covered by the advice here:

  • astra-toolbox/astra-toolbox: imports numpy.linalg.lapack_lite from C++ purely as a RTLD_DEEPBIND side-effect to stop MATLAB's MKL from clashing with numpy's LAPACK. It calls no routine at all.
  • BLAS/Fortran introspection recipes — e.g. simomarsili/ndd uses numpy.linalg.lapack_lite.__file__ to locate the .so and run ldd on it; the _ilp64 attribute is used elsewhere to detect 64-bit BLAS.

The former could use numpy.linalg._umath_linalg instead. I'm not sure if we need to explicitly document that though because it's an unusual thing to do. Maybe one of us could send in a PR to astra-toolbox and reference this PR?

The latter could use np.show_config() instead. We should probably explicitly suggest np.show_confg() in the deprecation warning for people who are using the module for introspection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants