Skip to content

Conversation

@ajpotts
Copy link
Contributor

@ajpotts ajpotts commented Jan 10, 2026

Add NumPy Alignment Tests for random.Generator

Summary

This PR introduces a new NumPy alignment test suite for ak.random.Generator, ensuring Arkouda’s RNG behavior remains consistent with NumPy where intended, and explicitly documenting known and intentional divergences.

The new tests focus on:

  • Scalar RNG calls that delegate directly to NumPy
  • Array RNG calls generated on the Arkouda server
  • API contracts (shape, dtype, bounds, error semantics)
  • Reproducibility guarantees
  • Known limitations and open bugs, captured as xfail

Changes

  • Added tests/numpy/alignment_verification/random_generator_alignment_test.py
  • Registered the new test file in pytest.ini so it runs as part of the NumPy alignment suite

Test Coverage Details

Scalar delegation (exact match)

When size is None, many Generator methods delegate directly to NumPy.
These tests assert exact agreement with numpy.random.default_rng for a fixed seed:

  • random
  • uniform
  • standard_normal
  • standard_exponential
  • integers
  • logistic
  • standard_gamma
  • poisson

These tests act as high-sensitivity detectors for RNG stream misalignment.

Server-generated arrays (contract + sanity)

For calls with size provided:

  • Verifies shape and dtype contracts
  • Checks value bounds
  • Confirms reproducibility for identical seeds
  • Avoids brittle bitwise comparisons against NumPy

Documented limitations (xfail)

Two known issues are intentionally captured as xfail:

  1. Float dtype not rejected by integers
    • Root cause: dtype identity check after normalization
    • Tracked separately (see linked issue)
  2. Mixed scalar + array call stream misalignment
    • Scalars use NumPy locally; arrays use server RNG
    • Streams are not yet unified

Encoding these as xfail prevents regressions while clearly signaling future work.

Why this matters

  • Aligns Arkouda RNG behavior more closely with NumPy expectations
  • Prevents silent API drift as RNG internals evolve
  • Provides a foundation for future stream-unification work
  • Improves confidence in reproducibility and correctness

Follow-ups

  • Fix Generator.integers to reject all floating-point dtypes

Testing

pytest tests/numpy/alignment_verification/random_generator_alignment_test.py

Closes #5297: alignment tests for arkouda.numpy.generator

@ajpotts ajpotts force-pushed the 5297_alignment_tests_for_arkouda.numpy.generator branch from 45b86bb to be7673b Compare January 13, 2026 20:07
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@be6b999). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5299   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         4           
  Lines           ?        63           
  Branches        ?         0           
========================================
  Hits            ?        63           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ajpotts ajpotts force-pushed the 5297_alignment_tests_for_arkouda.numpy.generator branch from be7673b to 86ee234 Compare January 16, 2026 16:49
@ajpotts ajpotts force-pushed the 5297_alignment_tests_for_arkouda.numpy.generator branch from 86ee234 to e650cf5 Compare January 16, 2026 17:01
@ajpotts ajpotts marked this pull request as ready for review January 16, 2026 21:15
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.

alignment tests for arkouda.numpy.generator

1 participant