Get a list of all displays from yohou.
Returns
| Name | Type |
Description |
displays |
list of tuples
|
List of (name, class), where name is the display class name as
string and class is the actual type of the class.
|
Examples
>>> from yohou.utils.discovery import all_displays
>>> displays = all_displays()
See Also
Source Code
View on GitHub
Show/Hide source
| def all_displays() -> list[tuple[str, type]]:
"""Get a list of all displays from `yohou`.
Returns
-------
displays : list of tuples
List of (name, class), where ``name`` is the display class name as
string and ``class`` is the actual type of the class.
Examples
--------
>>> from yohou.utils.discovery import all_displays
>>> displays = all_displays()
See Also
--------
- [`all_estimators`][yohou.utils.discovery.all_estimators] : Get all estimator classes from yohou.
- [`all_functions`][yohou.utils.discovery.all_functions] : Get all public functions from yohou.
"""
all_classes = []
root = str(Path(__file__).parent.parent) # yohou package
# Ignore deprecation warnings triggered at import time and from walking
# packages
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)
for _, module_name, _ in pkgutil.walk_packages(path=[root], prefix="yohou."):
module_parts = module_name.split(".")
if any(part in _MODULE_TO_IGNORE for part in module_parts):
continue
try:
module = import_module(module_name)
except ImportError:
continue
classes = inspect.getmembers(module, inspect.isclass)
classes = [
(name, display_class)
for name, display_class in classes
if not name.startswith("_") and name.endswith("Display")
]
all_classes.extend(classes)
return sorted(set(all_classes), key=itemgetter(0))
|