Skip to content

[BUG] np.int_ causes 32-bit Overflow on Windows (NumPy < 2.0) #3201

@Adityakushwaha2006

Description

@Adityakushwaha2006

Describe the bug

I encountered a critical platform dependency issue where np.int_ is used for indexing and array initialization in core utilities (e.g., aeon/utils/windowing.py).

While np.int_ maps to a 64-bit integer on Linux/macOS, it maps to a 32-bit C long on Windows (even on 64-bit systems). This causes an OverflowError (or silent data corruption if wrapping occurs) when handling indices or strides larger than 2,147,483,647 (approx. 2.14 billion), effectively breaking aeon for large-scale time series on Windows.

Steps/Code to reproduce the bug

Run the following script on a Windows machine vs. a Linux environment (e.g., Colab).


import numpy as np
import sys

print(f"OS Platform: {sys.platform}")
print(f"NumPy Version: {np.__version__}")

# np.int_ corresponds to C 'long'
# Windows: 32-bit (4 bytes)
# Linux/Mac: 64-bit (8 bytes)
int_size = np.dtype(np.int_).itemsize
print(f"Size of np.int_ (C long): {int_size * 8}-bit")

# Attempt to store a value > 2.14 Billion (32-bit limit)
test_value = 3_000_000_000
print(f"Attempting to store: {test_value}")

try:
    # This crashes on Windows but works on Linux
    val = np.array([test_value], dtype=np.int_)
    print(f"Success: {val[0]}")
except Exception as e:
    print(f"FAIL: {e}")

Expected results

The code should handle standard large integers (64-bit) consistently across all supported 64-bit platforms (Windows, Linux, macOS), allowing the storage of values > 2.14 billion without crashing.

Actual results

On Windows (Reproduction Log)[for most of the users' numpy version] :

OS Platform: win32
NumPy Version: 1.26.4
Size of np.int_ (C long): 32-bit
Attempting to store: 3000000000
FAIL: OverflowError: Python int too large to convert to C long

On Linux:

OS Platform: linux
NumPy Version: 2.0.2
Size of np.int_ (C long): 64-bit
Attempting to store: 3000000000
Success: 3000000000

Versions

  • OS: Windows 11 (64-bit)
  • Python: 3.x (64-bit)
  • NumPy: 1.26.4 (Windows) vs 2.0.2 (Linux) -fails
  • NumPy: 2.0.2 (Windows) vs 2.0.2 (Linux) -passes
  • aeon version: v0.13.0 (dev)

Results: Tested and confirmed , once fixes are applied, the functionality is consistent across all numpy versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature, improvement request or other non-bug code enhancementgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions