Skip to content

Result of numpy.sum with float32 input is float64 #152

Closed
@mdhaber

Description

@mdhaber

IIUC the standard states that input dtype is to be preserved for floating point types when dtype is unspecified.

dtype - data type of the returned array. If None, the returned array must have the same data type as x, unless x has an integer data type

However,

from array_api_compat import numpy as np
x = np.arange(10, dtype=np.float32)
np.sum(x).dtype  # dtype('float64')

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