8000 sum() should return +inf when it fails due to rounding errors · Issue #15785 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
sum() should return +inf when it fails due to rounding errors  #15785
Closed
@PBarde

Description

@PBarde

This is related to the issue #13734
but in this example it is not a difference in term of the 7th significant number, the value returned by the sum is unusable and I think an error should be raised or the result should be +inf

Reproducing code example:

import numpy as np
a = np.ones((3, 2000, 115), dtype=np.float16)
x = a[0].sum(0)[110]
y = a[0, :, 110].sum(0)

print(x)
# 2000.0

print(y)
# 2000.0

#########

a = np.ones((3, 3000, 115), dtype=np.float16)
x = a[0].sum(0)[110]
y = a[0, :, 110].sum(0)

print(x)
# 2048.0

print(y)
# 3000.0

#########

a = np.ones((3, 6000, 115), dtype=np.float16)
x = a[0].sum(0)[110]
y = a[0, :, 110].sum(0)

print(x)
# 2048.0

print(y)
# 6000.0

Numpy/Python version information:

numpy version : 1.18.2
python version : 3.8.1

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

      0