Skip to content

Commit f1881c6

Browse files
committed
task: review fixes
1 parent 8a8b942 commit f1881c6

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

.pylintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

mkl_random/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@
155155
"shuffle",
156156
"permutation",
157157
"interfaces",
158+
"patch_numpy_random",
159+
"restore_numpy_random",
160+
"is_patched",
161+
"patched_names",
158162
]
159163

160164
del _init_helper

mkl_random/tests/test_patch.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ def test_patch_and_restore():
6868
assert np.random.RandomState is orig_RandomState
6969

7070

71+
def test_patch_with_limited_names():
72+
"""Test patching only selected functions via names keyword."""
73+
orig_normal = np.random.normal
74+
orig_randint = np.random.randint
75+
assert not mkl_random.is_patched()
76+
77+
try:
78+
mkl_random.patch_numpy_random(np, names=["normal"])
79+
assert mkl_random.is_patched()
80+
assert np.random.normal is _nrand.normal
81+
assert np.random.randint is orig_randint
82+
83+
names = mkl_random.patched_names()
84+
assert "normal" in names
85+
assert "randint" not in names
86+
finally:
87+
mkl_random.restore_numpy_random()
88+
89+
assert not mkl_random.is_patched()
90+
assert np.random.normal is orig_normal
91+
assert np.random.randint is orig_randint
92+
93+
7194
def test_context_manager():
7295
"""Test context manager patching and automatic restoration."""
7396
orig_uniform = np.random.uniform

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ line_length = 80
9393
multi_line_output = 3
9494
use_parentheses = true
9595

96+
[tool.pylint.main]
97+
extension-pkg-allow-list = ["numpy", "mkl_random.mklrand"]
98+
99+
[tool.pylint.typecheck]
100+
generated-members = ["RandomState", "min", "max"]
101+
96102
[tool.setuptools]
97103
include-package-data = true
98104

0 commit comments

Comments
 (0)