Skip to content

DOC: clarify fromstring requires sep argument - #32798

Open
michaelzhan1 wants to merge 2 commits into
numpy:mainfrom
michaelzhan1:doc/fromstring/binary-mode
Open

michaelzhan1 wants to merge 2 commits into
numpy:mainfrom
michaelzhan1:doc/fromstring/binary-mode

Conversation

@michaelzhan1

@michaelzhan1 michaelzhan1 commented Sep 27, 2026 •

Copy link
Copy Markdown

PR summary

Addresses one issue mentioned in #27038, which describes that np.fromstring's documentation doesn't match its behavior when omitting sep or passing in sep='' (the binary mode behavior was removed in release 2.3.0).

I updated the fromstring docs by:

  • Removing mention of binary mode from the dtype argument, since the functionality was removed
  • Removing "optional" from the sep argument, and clarifying that it must not be empty
  • Switching the deprecated callout to a versionchanged callout
  • Updating the ValueError condition
    • The previous condition references binary mode error checks, but the binary mode guard makes this impossible to reach

I also updated the ValueError message itself to clearly state that sep is required and must not be empty.

First time contributor introduction

Hi! I'm Michael from Bloomberg, participating in the NumFOCUS Open Source program. I use NumPy mostly for personal projects nowadays, but have used it for work and school projects in the past.

AI Disclosure

I used Claude Opus 5.5 to help understand parts of the codebase relevant to the listed issue, particularly how the C functions are exposed and how the documentation is generated. I also used Claude to review the changes locally as a sanity check to increase confidence (for myself) in the completeness of my changes. The code, documentation, and this PR description are all hand-written. I will participate in the PR manually.

@tylerjereddy tylerjereddy added the sustain-2026 Issues reserved for NumFOCUS Sustaining Open Source Series 2026 label Sep 27, 2026

@mattip mattip 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.

Thanks for the PR. This doesn't fix the weird np.dtype(np.dtype) call path creating the error when a dtype class is fed to the function. Is that intentional? If so the PR should not close the issue.

Comment on lines +2367 to +2368
"fromstring() requires a non-empty 'sep' argument. Its binary mode" \
" was removed, use frombuffer() 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.

AI tries to preserve historical context when none is needed. Restate this without the "was removed", maybe something like

Suggested change
"fromstring() requires a non-empty 'sep' argument. Its binary mode" \
" was removed, use frombuffer() instead.");
"fromstring() requires a non-empty 'sep' argument. See frombuffer()");

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.

If I include a mention to frombuffer at all, then I'd like to keep a reference to a binary input, since otherwise the pointer to frombuffer seems to not have specific motivation. Maybe something like

fromstring() requires a non-empty 'sep' argument. See frombuffer() for binary inputs.

But since the fromstring docs describe the binary mode change and frombuffer recommendation, maybe I can just simplify it all to (and maybe leave a comment in-code explaining why?)

fromstring() requires a non-empty 'sep' argument.

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.

Great. Less is more.

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.

Updated the error message

@michaelzhan1

Copy link
Copy Markdown
Author

No, it doesn't address the np.dtype(np.dtype) issue; it only attempts to fix the fromstring documentation. I can remove the closes directive in the description.

To me, it feels like #27038 covers a few topics, one of which this PR attempts to cover. Is the general standard within NumPy to break this issue into multiple smaller issues, or to leave this issue and resolve it across multiple PRs?

@mattip

mattip commented Sep 28, 2026

Copy link
Copy Markdown
Member

The two are indeed very different, so let's leave the issue open and leave this a doc-only PR.

@michaelzhan1

Copy link
Copy Markdown
Author

Tagging @InessaPawson so that this PR can be added to the NF sprint tracker

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

04 - Documentation sustain-2026 Issues reserved for NumFOCUS Sustaining Open Source Series 2026

Projects

Development

Successfully merging this pull request may close these issues.

4 participants