Skip to content

Support integer inputs for ak.floor and ak.ceil (NumPy alignment) #5253

Closed

Description

@ajpotts

Support integer inputs for ak.floor and ak.ceil (NumPy alignment)

Summary

ak.floor and ak.ceil currently raise TypeError for integer inputs, while NumPy defines these ufuncs for integer arrays as identity operations (i.e., no-op, returning the same values).

This discrepancy causes failures in NumPy alignment tests and represents a gap between Arkouda and NumPy semantics.

Current Behavior

>>> import arkouda as ak
>>> import numpy as np

>>> a = ak.array([1, 2, -3], dtype=ak.int64)
>>> ak.floor(a)
TypeError: floor only implements types [<class 'float'>]

In NumPy:

>>> np.floor(np.array([1, 2, -3], dtype=np.int64))
array([ 1.,  2., -3.])

Expected / Desired Behavior

Two reasonable alignment options:

Recommendation

  • Allow integer inputs for ak.floor and ak.ceil
  • Return an array equivalent to NumPy behavior:
    • Either identical integer values
    • Or float output matching NumPy’s casting rules

Rationale

  • NumPy defines floor and ceil for all real-valued dtypes, including integers
  • Alignment reduces surprise and simplifies user code paths
  • Integer support can be implemented cheaply as a fast-path / no-op

Suggested Implementation Sketch

In arkouda/numpy/numeric.py:

if pda.dtype.kind in "iu":
    return pda.astype(ak.float64)  # or return pda unchanged if int output is desired

(or equivalent logic consistent with Arkouda dtype policy)

Tests

  • Update NumPy alignment tests to expect:
    • Successful execution for integer inputs
    • Output matching NumPy semantics

Impact

  • Improves NumPy compatibility
  • Low risk change (no existing valid code relies on raising here)
  • Helps stabilize alignment verification suite

Activity

  1. added
    bug
    and removed
    bug
    on Jan 7, 2026
  2. self-assigned this
    on Feb 2, 2026
  3. drculhane commented on Feb 2, 2026

    @drculhane
    Contributor

    Good catch. There is another function, round, which also has this issue.

    numpy floor and ceil include a dtype parameter, which the corresponding arkouda functions don't, so that will have to be added, too.

    numpy round doesn't have that parameter, but it does have a decimal parameter, indicating the number of decimal places to round to.

    I'm inclined to fix all of these when addressing this issue, and add new unit tests.

  4. added a commit that references this issue on Feb 11, 2026
    b58bccb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions