Skip to content

BUG: possible problem with np.add.accumulate on 32-bit windows #20699

@mhvk

Description

@mhvk

Describe the issue:

In astropy, there are several failures with numpy 1.22. Most seem related to precision issues, perhaps due to the intel short vector math library. Those we can fix. A very strange one is a failure on win32 only: https://github.com/astropy/astropy/runs/4680891863?check_suite_focus=true, with the most relevant bit being:

>                   raw_field[1:, 1] = (np.add.accumulate(raw_field[:-1, 0]) *
                                        dtype.itemsize)
E                   TypeError: the resolved dtypes are not compatible with add.accumulate. Resolved (dtype('int32'), dtype('int32'), dtype('int32'))

The crucial bit seems to be a call that should be the equivalent of (sorry, don't have a windows machine so cannot test directly...),

np.add.accumulate(np.arange(10, dtype='>i4'))

On linux, this does not give any errors, though I can get the same TypeError by passing in an explicit dtype,

np.add.accumulate(np.arange(10, dtype='>i4'), dtype=np.int32)

This same line does not give an error on numpy 1.21.5, so that suggests this problem has to do with the new ufunc/dtype machinery, perhaps doing a wrong inference of the dtype on win32? Hence, cc @seberg.

Reproduce the code example:

import numpy as np
np.add.accumulate(np.arange(10, dtype='>i4'))

Error message:

No response

NumPy/Python version information:

platform win32 -- Python 3.9.9
3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)]
Numpy: 1.22.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