Overview
This release introduces NumPy compatibility through a new patching system and dedicated interface module. mkl_random can now seamlessly replace NumPy's random number generation while maintaining full API compatibility. The release includes extensive test coverage from NumPy's test suite, numerous bug fixes, and improvements to align with modern NumPy behavior. Python 3.9 support has been dropped.
Highlights
🔄 NumPy Patching System
- New context manager and explicit patch/restore functions to replace
numpy.randomwithmkl_randomimplementations - Query patching status with
is_patched()function - Seamless drop-in replacement for NumPy's random number generation
🎯 Strict NumPy API Interface
- New
mkl_random.interfaces.numpy_randommodule provides pure NumPy-compatible API - Aliases mkl_random functionality while dropping non-standard arguments and functions
- Better alignment with NumPy's API contracts
✅ Enhanced Test Coverage
- Third-party tests from
numpy.randomintegrated to validate compatibility - Additional vendored NumPy tests for comprehensive validation
- Improved reliability and correctness
🐛 Bug Fixes & Improvements
- Fixed hang in
zipfwhen called withnp.nan - Fixed size-1 1D arrays being incorrectly cast to scalars
- Multiple implementation updates to align with newer NumPy versions
📦 Flexible Build Configuration
- Conda recipe now supports configurable NumPy dependency via
USE_NUMPY_BASEenvironment variable
- Python 3.9 support dropped - Minimum supported version is now Python 3.10+
mkl_random.RandomStatedeprecated - Usemkl_random.MKLRandomStateinstead.RandomStatenow delegates to thenumpy_randominterface for compatibility.
Python Version Support
- ✅ Python 3.10, 3.11, 3.12, 3.13, 3.14
- ❌ Python 3.9 and earlier
Detailed Changes
Added
-
Added
mkl_randompatching for NumPy, withmkl_randomcontext manager,is_patchedquery, andpatch_numpy_randomandrestore_numpy_randomcalls to replacenumpy.randomcalls with calls frommkl_random.interfaces.numpy_randomgh-90 -
Added
mkl_random.interfaceswithmkl_random.interfaces.numpy_randominterface, which aliasesmkl_randomfunctionality to more strictly adhere to NumPy's API (i.e., drops arguments and functions which are not part of standard NumPy) gh-92 -
Added third-party tests from
numpy.randomwhich tests themkl_random.interfaces.numpy_randominterface gh-103
Changed
- Updates to
mkl_randomimplementations to better align with newer versions ofnumpy.randomgh-103, gh-115 - Made conda recipe dependency on numpy configurable through
USE_NUMPY_BASEenvironment variable gh-105
Fixed
- Various bugfixes including a hang in
zipfwhen called withnp.nanand size-1 1D arrays being cast to scalars gh-103, gh-115
Removed
- Dropped support for Python 3.9 gh-81
Deprecated
- Deprecated
mkl_random.RandomStatein favor ofmkl_random.MKLRandomState, delegatingmkl_random.RandomStateto themkl_random.interfaces.numpy_randominterface gh-92
Contributors
- Anton Volkov (@antonwolfy)
- Nikita Grigorian (@ndgrigorian)
New Contributors
- Jordan Harlow (@jharlow-intel)
Full Changelog: v1.3.1...v1.4.0