Skip to content

Bug: ak.isfinite fails on non-float dtypes (int/uint/bool) #5248

@ajpotts

Description

@ajpotts

Bug: ak.isfinite fails on non-float dtypes (int/uint/bool)

Summary

ak.isfinite raises a runtime error when called on integer, unsigned integer, or boolean arrays. This diverges from NumPy semantics, where isfinite is defined for all numeric dtypes and always returns True for non-floating inputs.

Expected Behavior (NumPy)

np.isfinite(np.array([1, 2, 3], dtype=int))      # array([True, True, True])
np.isfinite(np.array([1, 2, 3], dtype=uint64))   # array([True, True, True])
np.isfinite(np.array([True, False]))             # array([True, True])

Actual Behavior (Arkouda)

ak.isfinite(ak.array([1, 2, 3]))

Raises:

RuntimeError: Error executing command isfinite<1>: cannot cast class to type - runtime types not compatible

This occurs for:

  • int64
  • uint64
  • bool

Root Cause

The Arkouda backend dispatches isfinite<1> for non-float inputs, but the server kernel expects floating-point types and fails during runtime casting.

Impact

  • NumPy alignment tests fail
  • Users cannot safely call ak.isfinite on non-float arrays
  • Inconsistent behavior relative to NumPy and pandas expectations

Proposed Fix

Short-circuit ak.isfinite for non-floating dtypes in the Python wrapper:

  • If dtype is integer, unsigned, or boolean:
    • Return ak.full(x.size, True, ak.bool)
  • Only dispatch the server-side isfinite kernel for floating-point inputs

This exactly matches NumPy semantics and avoids unnecessary server calls.

Temporary Workaround (Tests)

Mark isfinite for non-float kinds as xfail in NumPy-alignment tests until the backend behavior is fixed.

Related Test Failure

test_unary_alignment[False-isfinite-isfinite-isfinite-kinds]
RuntimeError: cannot cast class to type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions