Skip to content

DOC: clarify NpzFile handling of non-.npy archive members#30893

Closed
LarytheLord wants to merge 1 commit intonumpy:mainfrom
LarytheLord:docs/npzfile-non-npy-docs-26004
Closed

DOC: clarify NpzFile handling of non-.npy archive members#30893
LarytheLord wants to merge 1 commit intonumpy:mainfrom
LarytheLord:docs/npzfile-non-npy-docs-26004

Conversation

@LarytheLord
Copy link
Copy Markdown

Summary

  • update numpy.lib.npyio.NpzFile docs to match current runtime behavior
  • clarify that .npy members are loaded as arrays, while non-.npy members are returned as raw bytes
  • clarify files attribute wording: it lists all archive members, with .npy suffix removed where present

Closes #26004.

Validation

  • python3 -m compileall numpy/lib/_npyio_impl.py

@jorenham jorenham changed the title DOC: clarify NpzFile handling of non-.npy archive members DOC: clarify NpzFile handling of non-.npy archive members Feb 27, 2026
@jorenham
Copy link
Copy Markdown
Member

I'm not sure what python3 -m compileall numpy/lib/_npyio_impl.py does, but we use spin for building numpy and the docs: https://numpy.org/devdocs/dev/spin.html

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the NpzFile class documentation to accurately reflect its runtime behavior regarding non-.npy archive members. The original documentation incorrectly stated that files without a .npy extension are ignored, but the actual implementation loads them as raw bytes. This fixes issue #26004 by clarifying that .npy files are loaded as arrays while other files can be read as raw bytes.

Changes:

  • Clarified that files with .npy extension are loaded as NumPy arrays, while other files are returned as raw bytes
  • Updated the files attribute description to indicate it lists all archive members (not just .npy files), with .npy extensions removed where present
  • Updated the description text to accurately reflect that .npy extension removal happens for all files in the archive

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LarytheLord
Copy link
Copy Markdown
Author

Thanks for the note. You’re right: compileall was only a quick syntax sanity check on my side, not a NumPy build/doc validation step. I’ll use spin for validation notes on NumPy PRs going forward.

@jorenham jorenham requested review from Copilot and removed request for Copilot February 27, 2026 09:41
@LarytheLord
Copy link
Copy Markdown
Author

CI note: the current GCC / riscv64 failures appear infra-related (Could not resolve ports.ubuntu.com during apt install), before test/build steps run. This does not look specific to the doc change in this PR.

@LarytheLord
Copy link
Copy Markdown
Author

Closing this to reduce review load after opening too many PRs too quickly. I apologize for the noise.

@rkern
Copy link
Copy Markdown
Member

rkern commented Feb 27, 2026

I'm not sure what python3 -m compileall numpy/lib/_npyio_impl.py does, but we use spin for building numpy and the docs: https://numpy.org/devdocs/dev/spin.html

It's a Claudism. It likes to check that the Python it wrote is syntactically valid with compileall.

@LarytheLord
Copy link
Copy Markdown
Author

Fair point, and thanks for calling it out.

I should have validated this using NumPy’s documented spin workflow and reported that, instead of using a generic syntax check. I’ve stopped the batch-PR behavior and I’m being more deliberate with project-specific validation and communication.

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.

DOC: NpzFile is documented to ignore files without a .npy extension - but it doesn't

4 participants