Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: scalars don't have dlpack support #27137

@arogozhnikov

Description

@arogozhnikov

Describe the issue:

reduction (e.g. xp.sum) are expected to produce arrays, but in numpy they produce scalars, that don't follow array api specifications (e.g. I can't use dlpack on those).

In numpy v1, np.array_api correctly returned arrays in this case

Reproduce the code example:

import numpy as np
x = np.zeros([3, 4])

type(x.__array_namespace__().sum(x))
# outputs: numpy.float64 expected: numpy.ndarray

Python and NumPy Versions:

2.0.1
3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions