File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 155155 "shuffle" ,
156156 "permutation" ,
157157 "interfaces" ,
158+ "patch_numpy_random" ,
159+ "restore_numpy_random" ,
160+ "is_patched" ,
161+ "patched_names" ,
158162]
159163
160164del _init_helper
Original file line number Diff line number Diff 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+
7194def test_context_manager ():
7295 """Test context manager patching and automatic restoration."""
7396 orig_uniform = np .random .uniform
Original file line number Diff line number Diff line change @@ -93,6 +93,12 @@ line_length = 80
9393multi_line_output = 3
9494use_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 ]
97103include-package-data = true
98104
You can’t perform that action at this time.
0 commit comments