Skip to content

Conversation

@ajpotts
Copy link
Contributor

@ajpotts ajpotts commented Jan 10, 2026

Add NumPy-alignment tests for legacy random API (bool randint discrepancy tracked)

Summary

This PR adds a NumPy-alignment test suite covering Arkouda’s legacy random API, with an emphasis on:

  • shape semantics
  • value bounds
  • dtype behavior
  • error-message alignment with NumPy’s legacy RandomState

A known discrepancy in randint(dtype=bool) error messages is intentionally captured and marked as xfail, so the suite documents the divergence without breaking CI.

What’s included

  • New test module:
    • tests/numpy/alignment_verification/random_legacy_alignment.py
  • Added to pytest.ini test discovery
  • Coverage for:
    • ak.random.rand (scalar and multi-dimensional shapes)
    • ak.random.randint (int64 bounds and shape semantics)
    • ak.random.uniform
    • ak.random.standard_normal (distribution sanity checks)
    • ak.random.random

NumPy alignment strategy

For randint(dtype=bool), expected error messages are derived dynamically from:

numpy.random.RandomState.randint(..., dtype=bool)

This avoids hard-coding fragile strings and ensures the tests track NumPy’s actual behavior.

Known discrepancy (xfail)

For randint(dtype=bool) with negative low:

  • NumPy raises:
    ValueError: low is out of bounds for bool
    
  • Arkouda currently raises:
    ValueError: low < 0
    

This mismatch is explicitly detected and marked with:

pytest.xfail(... Issue #5295)

so CI remains green while preserving a clear signal that behavior differs from NumPy.

Why this matters

  • Establishes a reusable pattern for NumPy-alignment testing
  • Makes random API differences explicit and actionable
  • Prevents silent divergence in user-facing behavior

Follow-up

Once Arkouda’s randint(dtype=bool) validation is updated to match NumPy’s error message, the xfail can be removed and the test will pass automatically.

Closes 5294: alignment tests for arkouda.numpy.random.legacy

@ajpotts ajpotts changed the title Closes 5294: alignment tests for arkouda.numpy.random.legacy Closes #5294: alignment tests for arkouda.numpy.random.legacy Jan 10, 2026
@ajpotts ajpotts force-pushed the 5294_alignment_tests_for_arkouda.numpy.random.legacy branch from f886047 to 1e7f3b4 Compare January 13, 2026 20:07
@ajpotts ajpotts force-pushed the 5294_alignment_tests_for_arkouda.numpy.random.legacy branch from 1e7f3b4 to 978d7e4 Compare January 16, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant