Skip to content

Bug: char.isnumeric returns True for empty strings (NumPy mismatch) #5243

Open

Description

@ajpotts

Bug: char.isnumeric returns True for empty strings (NumPy mismatch)

Summary

arkouda.numpy.char.isnumeric does not match NumPy/Python semantics for empty strings.
Specifically, Arkouda returns True for "", while NumPy (np.char.isnumeric) and Python (str.isnumeric) return False.

This was discovered via a new NumPy-alignment verification test.


Expected Behavior (NumPy / Python)

"".isnumeric()              # False
np.char.isnumeric([""])    # array([False])

Actual Behavior (Arkouda)

ak.char.isnumeric(ak.array([""]))  
# pdarray([True])

This causes a mismatch in NumPy-alignment tests.


Failing Test

tests/numpy/alignment_verification/char_alignment.py::
TestArkoudaNumpyCharAlignment::test_isnumeric_matches_numpy_char

Mismatch at index 0:
value=''
got=True
expected=False

Root Cause (Likely)

The current implementation treats strings as numeric if all characters are numeric.
For empty strings, this condition is vacuously true, resulting in an incorrect True.


Proposed Fix

Update Strings.isnumeric() (or arkouda.numpy.char.isnumeric) to explicitly treat empty strings as non-numeric, matching NumPy semantics.

Conceptually:

isnumeric(s) = (len(s) > 0) AND all_characters_numeric(s)

Possible implementation:

  • AND the existing result with (self != ""), or
  • AND with (string_lengths > 0) if lengths are readily available.

Why This Matters

  • Aligns Arkouda string semantics with NumPy and Python
  • Prevents subtle downstream bugs in pandas/NumPy compatibility layers
  • Strengthens the new NumPy-alignment test suite

Environment

  • Arkouda client: 2025.12.16+
  • Arkouda server: 2025.12.16+ (minor version mismatch warning present but not believed to be causal)
  • Tests executed against a live Arkouda server

Activity

  1. added
    bug
    on Jan 6, 2026
  2. added a commit that references this issue on Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions