Skip to content

argsort: default value of stable not tested #389

Closed

Description

@cakedev0

See issue: data-apis/array-api-compat#354

This section of the test:

    kw = data.draw(
        hh.kwargs(
            axis=st.integers(-x.ndim, x.ndim - 1),
            descending=st.booleans(),
            stable=st.booleans(),
        ),
        label="kw",
    )

Probably enforces there are always kwargs, so we don't test default values to behave as expected...

Edit: this isn't true, missing kwargs are tested by hypothesis.

The problem comes from the fact that tested arrays are too small.

It's a common optimization in sorting algorithms to switch to insertion sort for small arrays, and insertion sort is inherently stable. See #define SMALL_QUICKSORT 15 constant in numpy's code for instance.

More generally, it's common to switch strategy for small arrays in sorting algorithm, so it's good to test long enough arrays when testing sort/argsort.

Activity

  1. changed the title [-]Sort-stability is not verified in argsort tests[/-] [+]argsort: default value of stable not tested[/+] on Oct 2, 2025
  2. cakedev0 commented on Oct 2, 2025

    @cakedev0
    ContributorAuthor

    I would have been happy to write the PR, but the heavy use of hypothesis makes it hard for me, I don't know this lib.

    Edit: I did the PR in the end: #390

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions