FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: update __module__ in numpy.random module by charris · Pull Request #27911 · numpy/numpy · GitHub

/ numpy Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .pyx  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 3 additions & 0 deletions numpy/random/_generator.pyx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5082,3 +5082,6 @@ def default_rng(seed=None):
# Otherwise we need to instantiate a new BitGenerator and Generator as
# normal.
return Generator(PCG64(seed))


default_rng.__module__ = "numpy.random"
11 changes: 11 additions & 0 deletions numpy/random/mtrand.pyx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4956,3 +4956,14 @@ __all__ = [
'zipf',
'RandomState',
]

seed.__module__ = "numpy.random"
ranf.__module__ = "numpy.random"
sample.__module__ = "numpy.random"
get_bit_generator.__module__ = "numpy.random"
set_bit_generator.__module__ = "numpy.random"

for method_name in __all__[:-1]:
method = getattr(RandomState, method_name, None)
if method is not None:
method.__module__ = "numpy.random"
9 changes: 8 additions & 1 deletion numpy/tests/test_public_api.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def test___module__attribute():
member_name not in [
"char", "core", "ctypeslib", "f2py", "ma", "lapack_lite",
"mrecords", "testing", "tests", "polynomial", "typing",
"random", # cython disallows overriding __module__
"mtrand", "bit_generator",
] and
member not in visited_modules # not visited yet
):
Expand All @@ -728,6 +728,13 @@ def test___module__attribute():
):
continue

# skip cdef classes
if member.__name__ in (
"BitGenerator", "Generator", "MT19937", "PCG64", "PCG64DXSM",
"Philox", "RandomState", "SFC64", "SeedSequence",
):
continue

incorrect_entries.append(
dict(
Func=member.__name__,
Expand Down

Back | FazBrowse Home | New Git URL