task: add patch methods for mkl_random#90
task: add patch methods for mkl_random#90jharlow-intel wants to merge 6 commits intoIntelPython:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds monkey-patching functionality to mkl_random, allowing users to temporarily or permanently replace numpy.random functions with their mkl_random equivalents. The implementation provides both imperative (monkey_patch(), restore()) and context manager (mkl_random.mkl_random()) interfaces.
Changes:
- Adds new
_patch.pyxCython module implementing patching logic with thread-local state tracking - Extends
setup.pyto build the new_patchextension module - Exports patch functions (
monkey_patch,use_in_numpy,restore,is_patched,patched_names,mkl_random) in__init__.py - Adds comprehensive test suite in
test_patch.pycovering basic patching, restoration, and context manager functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 13 comments.
| File | Description |
|---|---|
| setup.py | Adds Extension configuration for mkl_random._patch module |
| mkl_random/src/_patch.pyx | Implements core patching logic with thread-local storage, patch/unpatch methods, and context manager |
| mkl_random/init.py | Exports patch-related functions to public API |
| mkl_random/tests/test_patch.py | Adds tests for patching, restoration, context manager, and patched function behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
mkl_random/init.py:101
- The patching API is imported into the top-level package, but the new public symbols (
monkey_patch,use_in_numpy,restore,is_patched,patched_names,mkl_random) are not added to__all__. This makes the export surface inconsistent with the rest of this module (which explicitly enumerates public names) and can breakfrom mkl_random import *expectations.
from ._patch import monkey_patch, use_in_numpy, restore, is_patched, patched_names, mkl_random
from mkl_random import interfaces
__all__ = [
"MKLRandomState",
"RandomState",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
17e4489 to
5d178a8
Compare
cfb3a1c to
ad67f15
Compare
a2969a1 to
38fe23d
Compare
Gonna need some expert's eyes on this one, but it built fine and the tests look okay.
Definitely going to have to make sure it properly interfaced numpy.random though