Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: numpy.strings.str_len fails on null object #26389

Open
lithomas1 opened this issue May 6, 2024 · 1 comment
Open

BUG: numpy.strings.str_len fails on null object #26389

lithomas1 opened this issue May 6, 2024 · 1 comment
Labels

Comments

@lithomas1
Copy link
Collaborator

lithomas1 commented May 6, 2024

Describe the issue:

numpy.strings.str_len should put np.nan when in that position when encountering an string array with a missing value, but instead errors with

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The length of a null string is undefined

Reproduce the code example:

import numpy as np
a = np.array(["a", "b", None], dtype=np.dtypes.StringDType(na_object=None))
np.strings.str_len(a)

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The length of a null string is undefined

Python and NumPy Versions:

'2.1.0.dev0+git20240424.f8392ce'

Runtime Environment:

No response

Context for the issue:

No response

@ngoldbaum
Copy link
Member

This is by design. What would be a sensible value for the length of a null string? Note that numpy doesn't have support for missing integer values.

Also, separately, none of the string ufuncs support None as a NaN-like NA object that passes through operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants