Created
May 30, 2023 18:59
-
-
Save kandersolar/7dabb6941a9142f97f5b39d9e848504d to your computer and use it in GitHub Desktop.
List the public functions in pvlib
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
import pvlib | |
import pandas as pd | |
import numpy as np | |
def recurse(module): | |
objects = [] | |
for name in dir(module): | |
if name.startswith("_"): | |
continue | |
obj = getattr(module, name) | |
if (not hasattr(obj, '__module__') or not obj.__module__.startswith(module.__name__)) and \ | |
(not hasattr(obj, '__package__') or not obj.__package__.startswith(module.__name__)): | |
continue | |
if type(obj).__name__ == 'function': | |
objects.append(obj.__module__ + "." + obj.__name__) | |
if type(obj).__name__ == 'module': | |
objects.extend(recurse(obj)) | |
return np.unique(objects) | |
names = recurse(pvlib) | |
df = pd.DataFrame({'name': names}) | |
df['module'] = df['name'].str.split(".").str[1] | |
counts = df.groupby('module').count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment