Skip to content

default_device and default_dtype fail with NumPy < 2.1 #1078

Open

Description

@mdhaber

Based on CI failures I've been getting in scipy/scipy#26550, I believe these will fail:

import array_api_extra as xpx
import numpy as np
xpx.default_dtype(np)  # AttributeError: module 'numpy' has no attribute '__array_namespace_info__'
xpx.default_device(np)  # presumably would fail, too

I'm having trouble testing in Colab because I get an older array-api-extra with NumPy 2.0. Anyway, it makes sense, since NumPy only added __array_namespace_info__ in SciPy 2.1.


On a related note, it would be nice to have a function that returned that array-api-compat version of a namespace given the namespace. One can do, e.g., array_namespace(xp.asarray(0)) # skip device check but creating temporary arrays is exactly what default_dtype and default_device saves us from. Perhaps array_api_compat.array_namespace should also just accept backends?

Activity

  1. lucascolley commented on Oct 31, 2026

    @lucascolley
    Member

    To confirm, does xpx.default_dtype(array_api_compat.numpy) work as expected? If so, my initial reaction would be to close as not planned, given https://data-apis.org/array-api-extra/library-design.html#scope.

  2. mdhaber commented on Nov 1, 2026

    @mdhaber
    ContributorAuthor

    Yes. OK, but then it's unfortunate that ScIPy's internal xp_default_dtype was removed in favor of xpx.default_dtype.

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