Skip to content

Bug: unique_values/unique_counts: NaNs should not be treated as equal #855

Open
@crusaderky

Description

@crusaderky

sparse version checks

  • I checked that this issue has not been reported before list of issues.
  • I have confirmed this bug exists on the latest version of sparse.
  • I have confirmed this bug exists on the main branch of sparse.

Describe the bug

The Array API specification states for unique_* functions:

As nan values compare as False, nan values should be considered distinct.

In other words, it dictates behaviour equal to np.unique(..., equal_nan=False).

sparse.unique_* functions however treat NaNs as equal.

Steps or code to reproduce the bug

>>> from math import nan

>>> import array_api_strict as xp
>>> xp.unique_values(xp.asarray([math.nan, math.nan]))
Array([nan, nan], dtype=array_api_strict.float64)

>>> import sparse
>>> sparse.unique_values(sparse.asarray([math.nan, math.nan]))
array([nan])

Please describe your system.

sparse 0.16.0b4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorneeds triageIssue has not been confirmed nor labeled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions