8000 BUG: Histogram of float32 data · Issue #28823 · numpy/numpy · GitHub 8000
[go: up one dir, main page]

Skip to content
BUG: Histogram of float32 data #28823
Closed
Closed
@rad83

Description

@rad83

Describe the issue:

Computing histogram of float32 data drops small values only at particular positions within the dataset.
In the following code, the output of the histogram function will change, if either the DTYPE or ORDER is changed, resulting in (at least for ORDER) rather inconsistent behavior.

Reproduce the code example:

import numpy as np

DTYPE = 'float32' # ['float32' | 'float64']
ORDER = -1        # [-1 | +1]

dat = np.zeros(10, dtype=DTYPE)
dat[2] = 1
dat[7] = 1e-10
dat = dat[::ORDER]

axs = np.linspace(0, 1, dat.shape[0]+1)
print(np.histogram(axs[:-1], axs, weights=dat)[0])

Error message:

Python and NumPy Versions:

2.2.5
3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]

Runtime Environment:

[{'numpy_version': '2.2.5',
'python': '3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207]',
'uname': uname_result(system='Linux', node='book', release='6.13.8-arch1-1', version='#1 SMP PREEMPT_DYNAMIC Sun, 23 Mar 2025 17:17:30 +0000', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL',
'AVX512_SPR']}},
{'filepath': '/usr/lib/libgomp.so.1.0.0',
'internal_api': 'openmp',
'num_threads': 4,
'prefix': 'libgomp',
'user_api': 'openmp',
'version': None}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0