Skip to content

DOC: update defchararray docstrings from str/unicode to str_/bytes_ - #32760

Open
bymasha wants to merge 2 commits into
numpy:mainfrom
bymasha:doc-gh-20062-defchararray
Open

bymasha wants to merge 2 commits into
numpy:mainfrom
bymasha:doc-gh-20062-defchararray

Conversation

@bymasha

@bymasha bymasha commented Sep 23, 2026

Copy link
Copy Markdown

PR summary

Closes #20062 by addressing the remaining scope from the maintainer's last comment.

The comment mentions that Item 4 from the original issue (API change to an already-deprecated legacy class) is out of scope - if this holds, this PR closes the issue fully.

Problem

  • np.string_ and np.unicode_ were removed in NumPy 2.0 in favor of np.bytes_ and np.str_, but the docstrings in defchararray.py have not been updated to reflect that
  • thus, several functions and the chararray class still mentioned "str or unicode", "string and unicode", etc in the docstrings
  • the module still had a note at the top stating that some methods were only available in certain Python versions, which is no longer true

This PR

  • updates all remaining str/unicode references to str_/bytes_
  • makes the str and bytes ordering consistent throughout the module (used to be mixed)
  • removes the outdated Python-version note on methods

First time contributor introduction

Hey team, this is my first contribution to numpy - very exciting (: I use numpy daily in my work as a data engineer so would be awesome to make even a small contribution!

AI Disclosure

All the code changes were typed, no AI was used for that.
Did use Claude to scan through the defchararray.py after I finished to make sure I haven't missed anything and it helped me find a couple of spots were the wording change was still needed. Did the corrections manually.

Comment thread numpy/_core/defchararray.py Outdated
strides=None, order=None)

Provides a convenient view on arrays of string and unicode values.
Provides a convenient view on arrays of `str_` or `bytes_` values.

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.

Based on the build logs I need to fix this to str and bytes

Comment thread numpy/_core/defchararray.py Outdated
Length of each array element, in number of characters. Default is 1.
unicode : bool, optional
Are the array elements of type unicode (True) or string (False).
Are the array elements of type `str_` (True) or `bytes_` (False).

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.

Need to change this as well to str (True) or bytes (False)

@bymasha

bymasha commented Sep 23, 2026

Copy link
Copy Markdown
Author

Will push the above later today.

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

@bymasha Thank you for working on this! NumPy does rely on its test suite. Since the tests are currently failing, there is still some work to do before this is ready for review.

- Replace outdated str/unicode references with str_ / bytes_
  (np.string_ and np.unicode_ were removed in favor of np.str_
  and np.bytes_ in NumPy 2.0.)
- Remove the outdated note stating that method availability
  depends on the Python version.

See numpy#20062#
@bymasha
bymasha force-pushed the doc-gh-20062-defchararray branch from 16a7012 to 811c51b Compare September 24, 2026 16:21
@bymasha

bymasha commented Sep 24, 2026

Copy link
Copy Markdown
Author

Hi @InessaPawson this passes the tests now - ready for review! thank you!

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

Projects

Development

Successfully merging this pull request may close these issues.

DOC: unicode/str/bytes in Python 3

2 participants