Skip to content

BUG: is_array_api_obj(np.matrix(...)) == True #388

Closed

Description

@lucascolley
(Pdb) A.A
matrix([[1, 2, 3],
        [4, 5, 6]], dtype=int32)
(Pdb) scipy._external.array_api_compat.is_array_api_obj(A.A)
True

Activity

  1. lucascolley commented on Feb 11, 2026

    @lucascolley
    MemberAuthor

    also

    (Pdb) scipy._external.array_api_compat.is_numpy_array(A.A)
    True

    it looks like we are deliberately accepting np.ndarray subclasses, but I think we should special case rejecting np.matrix as a known bad-case. WDYT @ev-br ?

  2. ev-br commented on Feb 11, 2026

    @ev-br
    Member

    Ouch. Reject all ndarray subclasses, I'd say? Maybe , just maybe, whitelist np.memmap. actually not even that, not until someone checks it, someone who uses it (scikit-learn?). Other than memmap, just plain ndarray /whatever is needed for numpy scalars , np.generic.

  3. lucascolley commented on Feb 11, 2026

    @lucascolley
    MemberAuthor

    could you send a PR or would you prefer to review?

  4. ev-br commented on Feb 12, 2026

    @ev-br
    Member

    Feel free to beat me up sending the PR :-).

  5. ev-br commented on Apr 28, 2026

    @ev-br
    Member

    Sent a fix in gh-423, could you double-check it fixes the issue for you Lucas?

  6. added this to the 1.15 milestone on Apr 29, 2026
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions