Skip to content

add array_namespace option to return wrapped if possible, else native #168

Closed
@lucascolley

Description

@lucascolley

Since array_namespace(x, use_compat=None) now returns plain numpy, but released NumPy still has incompatibilities with the standard, we want to use use_compat=True in SciPy. However, since array-api-strict isn't wrapped, array_namespace throws a ValueError, so we have to use:

try:
    return array_api_compat.array_namespace(*_arrays, use_compat=True)
except ValueError:
    return array_api_compat.array_namespace(*_arrays, use_compat=None)

array-api-strict isn't special here, this goes for any standard-compliant library. It would be nice to have an option to do this without having to catch an exception. Alternatively, we could just wait until NumPy is fully compatible with the standard before making the native namespace the default, but I'm not sure how feasible that is as the standard continues to change.

x-ref scipy/scipy#21264

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