Skip to content

Commit 2395ea0

Browse files
committed
Implement _get_all_public_members
1 parent afccf29 commit 2395ea0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

array_api_compat/_internal.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import wraps
66
from inspect import signature
77

8+
89
def get_xp(xp):
910
"""
1011
Decorator to automatically replace xp with the corresponding array module.
@@ -41,3 +42,16 @@ def wrapped_f(*args, **kwargs):
4142
return wrapped_f
4243

4344
return inner
45+
46+
47+
def get_all_public_members(module, filter_=None):
48+
"""Get all public members of a module."""
49+
try:
50+
return getattr(module, '__all__')
51+
except AttributeError:
52+
pass
53+
54+
if filter_ is None:
55+
filter_ = lambda name: name.startswith('_') # noqa: E731
56+
57+
return map(dir(module), filter_)

0 commit comments

Comments
 (0)