Skip to content

ENH: add nunique delegation#861

Open
floze-the-genius wants to merge 1 commit into
data-apis:mainfrom
floze-the-genius:feat/nunique-delegation
Open

ENH: add nunique delegation#861
floze-the-genius wants to merge 1 commit into
data-apis:mainfrom
floze-the-genius:feat/nunique-delegation

Conversation

@floze-the-genius

Copy link
Copy Markdown

Completes the remaining nunique item in #100.

Summary

  • move the public nunique wrapper and backend dispatch into _delegation.py
  • delegate eager NumPy and CuPy arrays to native unique(..., equal_nan=False)
  • delegate eager PyTorch arrays to native unique, while retaining the generic fallback for devices such as meta that do not support data-dependent shapes
  • preserve the JAX static-size implementation and the lazy/array-agnostic fallback for Dask, strict, sparse, and wrapped namespaces
  • add a backend dispatch test that fails if supported native namespaces reach the generic implementation

The equal_nan=False argument preserves the existing Array API behavior where separate NaNs count as separate unique values.

Validation

  • pytest -q -p no:cacheprovider: 4347 passed, 8984 skipped, 18 xfailed, 2 xpassed
  • pytest -q -p no:cacheprovider tests/test_funcs.py::TestNUnique: 38 passed, 72 skipped in the lean environment
  • expanded focused backend run before slimming the environment: 75 passed, 34 skipped, 1 expected Dask xfail (NumPy, array-api-strict, Dask, sparse, PyTorch CPU/meta, and JAX CPU available)
  • ruff check on changed files
  • ruff format --check on changed files
  • numpydoc lint on changed implementation modules
  • validate-pyproject pyproject.toml
  • public export consistency test

CuPy could not be installed on this macOS host; its current native unique signature was checked to support equal_nan and CI covers the backend matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant