Skip to content

Cross-platform test failures due to np.int_ type differences in numba-jitted functions #59

@damar-wicaksono

Description

@damar-wicaksono

Several tests fail on certain platforms (e.g., Windows) due to type mismatches between test data and numba-jitted functions. Numba's njit requires explicit type declarations, which in this context is np.int_. However, the actual integer type varies across platforms and NumPy versions. When generating test data with np.random.randint(), the default dtype is also platform-dependent, which can create mismatches with the expected np.int_ type.

Affected tests

The affected tests are related to the following functions:

  • get_max_columnwise()
  • is_lex_smaller_or_equal()
  • is_lex_sorted()

Example

def test_get_max_columnwise():
    """Test getting the column-wise max of a two-dimensional integer array."""
    num_rows = np.random.randint(low=100, high=1000)
    num_cols = np.random.randint(low=1, high=10)
    xx = np.random.randint(low=0, high=100, size=(num_rows, num_cols))
    # xx.dtype differs between Linux (int64) and Windows (int32)

    max_ref = np.max(xx, axis=0)
    max_iter = get_max_columnwise(xx)  # Type mismatch on some platforms
    
    assert np.array_equal(max_ref, max_iter)

Proposed Solution

Explicitly specify dtype=INT_DTYPE when generating test data to match the numba function signatures.

Notes

This is strictly a testing issue. The functions themselves work correctly when called with appropriately typed arrays. The fix ensures test data matches the function signatures across all platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions