Skip to content

Instantly share code, notes, and snippets.

@bashtage
Created June 6, 2019 20:37
Show Gist options
  • Save bashtage/8f4eb7060a6518846ddad0bbb2897bdd to your computer and use it in GitHub Desktop.
Save bashtage/8f4eb7060a6518846ddad0bbb2897bdd to your computer and use it in GitHub Desktop.
Statsmodels release tool
"""
Dumps the complete statsmodels API to an Excel sheet
for use in preparing release
"""
import datetime as dt
import os
import pkgutil
import pandas as pd
from github import Github
import statsmodels
import statsmodels.api as sm
# 1. Dump statsmodels.api
version = statsmodels.__version__
official = pd.Series([f for f in dir(sm) if not f.startswith('_')])
official.to_excel(f'statamodels.api.{version}.xlsx')
# list all submodules of statsmodels
funcs = set()
for pkg in pkgutil.walk_packages(statsmodels.__path__,
statsmodels.__name__ + '.'):
if not pkg.ispkg:
print(pkg.name)
if ('.tests.' in pkg.name or
'.sandbox.' in pkg.name or
'make_tbls' in pkg.name or
'.compat.' in pkg.name):
continue
module = __import__(pkg.name, fromlist="dummy")
mod_funcs = []
for d in [v for v in dir(module) if not v.startswith('_')]:
a = getattr(module, d)
if hasattr(a, '__module__'):
if a.__module__ == pkg.name:
mod_funcs.append(pkg.name + '.' + d)
else:
if hasattr(a, '__file__'):
continue
funcs.update(mod_funcs)
pd.Series(sorted(funcs)).to_excel(f'statsmodels.complete.{version}.xlsx')
# %%
FIRST_DATE = dt.datetime(2018, 5, 15)
API_KEY = os.environ['GITHUB_API_KEY']
g = Github(API_KEY)
repo = g.get_repo('statsmodels/statsmodels')
closed = repo.get_pulls(state='closed')
merged = {}
for pr in closed:
print(pr)
if pr.is_merged():
merged[pr.number] = {'title': pr.title, 'author': pr.user,
'date': pr.merged_at}
merged_in_window = {key: val for key, val in merged.items() if
val['date'] >= FIRST_DATE}
TEMPLATE = '* (:issue:`{issue}`): {title}'
for key in sorted(merged_in_window.keys()):
pr = merged_in_window[key]
print(TEMPLATE.format(issue=key, title=pr['title']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment