Skip to content

DEP: Deprecate np.isfortran - #32722

Open
Riaz1729 wants to merge 41 commits into
numpy:mainfrom
Riaz1729:deprecate_isfortran
Open

Riaz1729 wants to merge 41 commits into
numpy:mainfrom
Riaz1729:deprecate_isfortran

Conversation

@Riaz1729

@Riaz1729 Riaz1729 commented Sep 21, 2026 •

Copy link
Copy Markdown

PR summary

Deprecates numpy.isfortran as the first half of addressing #6597

  • What problem does this PR solve? Link any relevant issues and PRs.
    Per Deprecate isfortran and a.flags.fnc #6597, this marks numpy.isfortran, which checks if an array is Fortran contiguous and not C contiguous. The DeprecationWarning directs users to directly use a.flags.fnc (which is called by numpy.isfortran).

At some point in the future we may be able to also deprecate a.flags.fnc if it is used minimally.

First time contributor introduction

I'm a new contributor and part of the NumFOCUS Volunteer Sprints Fall 2026 cohort. I wanted to take a simple issue first so that I could make sure that I understand and am comfortable following the contribution guidelines before moving to more involved issues.

AI Disclosure

I used Antigravity (Gemini 3..8 Flash) to help me understand the structure of the codebase so I could find the relevant modules quickly. I also used it to review my PR and it identified several places (including in the doc module) where to add additional notes/comments about the deprecation.

@Riaz1729 Riaz1729 changed the title DEP Deprecate np.isfortran DEP: Deprecate np.isfortran Sep 21, 2026
@Riaz1729
Riaz1729 force-pushed the deprecate_isfortran branch 4 times, most recently from 435cf61 to ba597bf Compare September 21, 2026 03:32
@Riaz1729
Riaz1729 marked this pull request as ready for review September 21, 2026 03:35
Comment thread numpy/_core/tests/test_deprecations.py Outdated
self.assert_deprecated(lambda: np.take(a, indices, out=different_dtype_out))

class TestIsfortran(_DeprecationTestCase):
# Deprecation in NumPy 2.5, 2026-09

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.

This should be 2.6 as dev builds right now are 2.6

different_dtype_out = np.zeros_like(indices, dtype=np.uint32)

self.assert_deprecated(lambda: np.take(a, indices, out=different_dtype_out))

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.

This might fail lint checks, have enabled the CI for you

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.

Interesting, I had assumed we enforce two blank lines before a class.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added the second newline in any case :)

Comment thread numpy/_core/numeric.py Outdated
"""
Check if the array is Fortran contiguous but *not* C contiguous.

.. deprecated:: 2.5

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.

Same as above, should be 2.6

Comment thread numpy/_core/numeric.pyi Outdated
def count_nonzero(a: ArrayLike, axis: _ShapeLike | None = None, *, keepdims: py_bool = False) -> Any: ...

#
@deprecated("numpy.isfortran is deprecated. Use a.flags.fnc instead.")

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.

Would be nice to have which version it was deprecated here.

Comment thread numpy/_core/numeric.py Outdated
`numpy.isfortran` is deprecated. Use ``a.flags.fnc`` instead.


This function is obsolete. If you only want to check if an array is Fortran

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.

nit: I think we can merge this as the above already states it's deprecated

@ganesh-k13 ganesh-k13 added the sustain-2026 Issues reserved for NumFOCUS Sustaining Open Source Series 2026 label Sep 21, 2026
@ganesh-k13 ganesh-k13 moved this from Open to Needs Review in NF Sustaining Open Source Series 2026 Sep 21, 2026
@InessaPawson InessaPawson moved this from Needs Review to In Progress in NF Sustaining Open Source Series 2026 Sep 23, 2026
Riaz1729 and others added 15 commits September 23, 2026 10:00
…#32595)

This optimizes two things: First the buffered iterator now allows buffer re-use reliably, but this  was not enabled in the non-reduce iteration loop (maybe accidentally).
Second, when the copy to the buffer can use trivial copies, this it now uses a direct copy approach for speed.

Especially the buffer-reuse can make a large speed difference when it kicks in.

Co-authored-by: Sebastian Berg <[email protected]>
danggeun and others added 25 commits September 23, 2026 11:39
Co-authored-by: Joren Hammudoglu <[email protected]>
Co-authored-by: Ralf Gommers <[email protected]>
Some overloads of `void.__getitem__()` and `generic.__getitem__()` had
overlapping signatures, which could cause type checkers (at least mypy)
to report errors in custom dtypes implemented downstream.
…n-deps group (numpy#32754)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Historically, we had to reject floats to match Python. But Python now always converts via `__index__` which makes this unnecessary. So we live in the future now where a float check is unnecessary to match Python `"i"` argparse behavior.
@Riaz1729
Riaz1729 requested a review from ganesh-k13 September 25, 2026 19:49

This branch has not been deployed

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

Labels

07 - Deprecation sustain-2026 Issues reserved for NumFOCUS Sustaining Open Source Series 2026

Projects

Development

Successfully merging this pull request may close these issues.