Skip to content

BUG: Bad SIMD integer // on windows in numpy 1.21.2 #20025

@Macky1979

Description

@Macky1979

Describe the issue:

I would like to report different behavior of % and // operands under numpy 1.20.3 and 1.21.2 running on Windows 10. The below code produces [0 0 0 0 0 0 0 0] for numpy 1.20.3 and [1 1 1 1 1 1 1 1] for numpy 1.21.2.

After upgrading numpy, I have noticed that pandas function groupby() is returning error of type IndexError: index 2 is out of bounds for axis 0 with size 2. The root of the cause is in function decons_group_index(), which is present in pandas file sorting.py. The issue is that groupby() determines unique values in individual columns and function decons_group_index() creates corresponding vector of indices. In my particular case I have two distinct values (e.g. 'a' and 'b') but three indices ([0, 1, 2]) when using numpy 1.21.2. Thus the error. In numpy 1.20.3 everything works fine. I suspect the following performance improvement being responsible for the issue.

Reproduce the code example:

import numpy as np

x = np.array([2076999867579399,
              2077965839147919,
              2078931810716439,
              2079897782284959,
              2080863753853479,
              2081829725421999,
              2082795696990519,
              2083761668559039])

y = np.array([0, 0, 0, 0, 0, 0, 0, 0])
factor = 160995261420
shape = 1

labels = (x - y) % (factor * shape) // factor

print(labels)

Error message:

No response

NumPy/Python version information:

1.21.2 3.9.6 (default, Aug 18 2021, 15:44:49) [MSC v.1916 64 bit (AMD64)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - Bugcomponent: SIMDIssues in SIMD (fast instruction sets) code or machinery

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions