Skip to content

xp.vecdot output arrayness depends on NumPy version #355

@mdhaber

Description

@mdhaber

With NumPy >= 2.0:

import numpy as np
from scipy._lib._array_api import array_namespace
x1 = np.asarray([0.667, 0.667, 0.667])
x2 = np.asarray([0.123, 0.456, 0.789])
xp = array_namespace(x1, x2)
xp.vecdot(x1, x2)
# np.float64(0.912456)

With NumPy < 2.0, the result is a 0d array.

I'd suggest that array-api-compat should either:

  • make modern NumPy produce an array (for compliance with the standard) or
  • make old NumPy produce a NumPy float (for consistency with all NumPy functions).

The latter would be my preference for now. (Actually fixing NumPy would be the long term preference - mdhaber/numpy#2).

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