Skip to content

Commit a7b9fde

Browse files
committed
chore: remove bad aliases
1 parent 3e6a331 commit a7b9fde

File tree

3 files changed

+21
-51
lines changed

3 files changed

+21
-51
lines changed

mkl_random/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,9 @@
9898
from ._patch_numpy import (
9999
is_patched,
100100
mkl_random,
101-
monkey_patch,
102101
patch_numpy_random,
103102
patched_names,
104-
restore,
105103
restore_numpy_random,
106-
use_in_numpy,
107104
)
108105

109106
__all__ = [

mkl_random/_patch_numpy.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -278,31 +278,6 @@ def restore_numpy_random(verbose=False):
278278
_patch.do_restore(verbose=bool(verbose))
279279

280280

281-
def monkey_patch(numpy_module=None, names=None, strict=False, verbose=False):
282-
"""Backward-compatible alias for patch_numpy_random()."""
283-
patch_numpy_random(
284-
numpy_module=numpy_module,
285-
names=names,
286-
strict=strict,
287-
verbose=verbose,
288-
)
289-
290-
291-
def use_in_numpy(numpy_module=None, names=None, strict=False, verbose=False):
292-
"""Backward-compatible alias for patch_numpy_random()."""
293-
patch_numpy_random(
294-
numpy_module=numpy_module,
295-
names=names,
296-
strict=strict,
297-
verbose=verbose,
298-
)
299-
300-
301-
def restore(verbose=False):
302-
"""Backward-compatible alias for restore_numpy_random()."""
303-
restore_numpy_random(verbose=verbose)
304-
305-
306281
def is_patched():
307282
"""
308283
Returns whether NumPy has been patched with mkl_random.

mkl_random/tests/test_patch.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@
3232
def test_is_patched():
3333
"""Test that is_patched() returns correct status."""
3434
assert not mkl_random.is_patched()
35-
mkl_random.monkey_patch(np)
35+
mkl_random.patch_numpy_random(np)
3636
assert mkl_random.is_patched()
37-
mkl_random.restore()
37+
mkl_random.restore_numpy_random()
3838
assert not mkl_random.is_patched()
3939

4040

41-
def test_monkey_patch_and_restore():
42-
"""Test monkey_patch replacement and restore of original functions."""
41+
def test_patch_and_restore():
42+
"""Test patch replacement and restore of original functions."""
4343
# Store original functions
4444
orig_normal = np.random.normal
4545
orig_randint = np.random.randint
4646
orig_RandomState = np.random.RandomState
4747

4848
try:
49-
mkl_random.monkey_patch(np)
49+
mkl_random.patch_numpy_random(np)
5050

5151
# Check that functions are now different objects
5252
assert np.random.normal is not orig_normal
@@ -58,7 +58,7 @@ def test_monkey_patch_and_restore():
5858
assert np.random.RandomState is mkl_random.RandomState
5959

6060
finally:
61-
mkl_random.restore()
61+
mkl_random.restore_numpy_random()
6262

6363
# Check that original functions are restored
6464
assert mkl_random.is_patched() is False
@@ -85,7 +85,7 @@ def test_context_manager():
8585

8686
def test_patched_functions_callable():
8787
"""Smoke test that patched functions are callable without errors."""
88-
mkl_random.monkey_patch(np)
88+
mkl_random.patch_numpy_random(np)
8989
try:
9090
# These calls should now be routed to mkl_random's implementations
9191
x = np.random.standard_normal(size=100)
@@ -100,53 +100,51 @@ def test_patched_functions_callable():
100100
assert z.shape == (10,)
101101

102102
finally:
103-
mkl_random.restore()
103+
mkl_random.restore_numpy_random()
104104

105105

106106
def test_patched_names():
107107
"""Test that patched_names() returns patched symbol names."""
108108
try:
109-
mkl_random.monkey_patch(np)
109+
mkl_random.patch_numpy_random(np)
110110
names = mkl_random.patched_names()
111111
assert isinstance(names, list)
112112
assert len(names) > 0
113113
assert "normal" in names
114114
assert "RandomState" in names
115115
finally:
116-
mkl_random.restore()
116+
mkl_random.restore_numpy_random()
117117

118118

119-
def test_monkey_patch_strict_raises_attribute_error():
119+
def test_patch_strict_raises_attribute_error():
120120
"""Test strict mode raises AttributeError for missing patch names."""
121121
# Attempt to patch a clearly non-existent symbol in strict mode.
122122
with pytest.raises(AttributeError):
123-
mkl_random.monkey_patch(np, strict=True, names=["nonexistent_symbol"])
124-
125-
126-
def test_use_in_numpy_is_alias_for_monkey_patch():
127-
"""Test use_in_numpy remains a backward-compatible alias."""
128-
assert hasattr(mkl_random, "use_in_numpy")
129-
assert mkl_random.use_in_numpy is mkl_random.monkey_patch
123+
mkl_random.patch_numpy_random(
124+
np,
125+
strict=True,
126+
names=["nonexistent_symbol"],
127+
)
130128

131129

132130
def test_patch_redundant_patching():
133131
orig_normal = np.random.normal
134132
assert not mkl_random.is_patched()
135133

136134
try:
137-
mkl_random.monkey_patch(np)
138-
mkl_random.monkey_patch(np)
135+
mkl_random.patch_numpy_random(np)
136+
mkl_random.patch_numpy_random(np)
139137
assert mkl_random.is_patched()
140138
assert np.random.normal is mkl_random.mklrand.normal
141-
mkl_random.restore()
139+
mkl_random.restore_numpy_random()
142140
assert mkl_random.is_patched()
143141
assert np.random.normal is mkl_random.mklrand.normal
144-
mkl_random.restore()
142+
mkl_random.restore_numpy_random()
145143
assert not mkl_random.is_patched()
146144
assert np.random.normal is orig_normal
147145
finally:
148146
while mkl_random.is_patched():
149-
mkl_random.restore()
147+
mkl_random.restore_numpy_random()
150148

151149

152150
def test_patch_reentrant():

0 commit comments

Comments
 (0)