diff --git a/examples/attributes.py b/examples/attributes.py index 4f3c452..ca28df9 100644 --- a/examples/attributes.py +++ b/examples/attributes.py @@ -50,7 +50,6 @@ def project(): if __name__ == '__main__': - set_option('display.height', 1000) set_option('display.max_rows', 500) set_option('display.max_columns', 500) set_option('display.width', 1000) diff --git a/examples/commit_history.py b/examples/commit_history.py index 1febb39..69848fc 100644 --- a/examples/commit_history.py +++ b/examples/commit_history.py @@ -3,6 +3,8 @@ import numpy as np from pandas import set_option +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' @@ -80,11 +82,10 @@ def repository(path): print(etns) if __name__ == '__main__': - set_option('display.height', 1000) set_option('display.max_rows', 500) set_option('display.max_columns', 500) set_option('display.width', 1000) - path = os.path.abspath('../../git-pandas') + path = os.path.abspath(GIT_PANDAS_DIR) project(path) repository(path) \ No newline at end of file diff --git a/examples/definitions.py b/examples/definitions.py new file mode 100644 index 0000000..b3d8723 --- /dev/null +++ b/examples/definitions.py @@ -0,0 +1,3 @@ +from pathlib import Path + +GIT_PANDAS_DIR = Path(__file__).resolve().parent.parent diff --git a/examples/file_change_rates.py b/examples/file_change_rates.py index 71b277f..7dd103a 100644 --- a/examples/file_change_rates.py +++ b/examples/file_change_rates.py @@ -1,10 +1,12 @@ import os from gitpandas import Repository +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' if __name__ == '__main__': - repo = Repository(working_dir=os.path.abspath('../../git-pandas')) + repo = Repository(working_dir=GIT_PANDAS_DIR) fc = repo.file_change_rates(include_globs=['*.py'], coverage=True) print(fc) \ No newline at end of file diff --git a/examples/hours_estimate.py b/examples/hours_estimate.py index aebc887..dbe8751 100644 --- a/examples/hours_estimate.py +++ b/examples/hours_estimate.py @@ -1,14 +1,14 @@ import os from gitpandas.repository import Repository +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' -# get the path of this repo -path = os.path.abspath('../../git-pandas') # build an example repository object and try some things out ignore_dirs = ['tests/*'] -r = Repository(path, verbose=True) +r = Repository(GIT_PANDAS_DIR, verbose=True) # get the hours estimate for this repository (using 30 mins per commit) he = r.hours_estimate( diff --git a/examples/parallel_blame.py b/examples/parallel_blame.py index e97a31a..b6fab83 100644 --- a/examples/parallel_blame.py +++ b/examples/parallel_blame.py @@ -1,11 +1,13 @@ from gitpandas import Repository import time +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' if __name__ == '__main__': - g = Repository(working_dir='..') + g = Repository(working_dir=GIT_PANDAS_DIR) st = time.time() blame = g.cumulative_blame(branch='master', include_globs=['*.py', '*.html', '*.sql', '*.md'], limit=None, skip=None) diff --git a/examples/project_blame.py b/examples/project_blame.py index ea345e6..dd62d64 100644 --- a/examples/project_blame.py +++ b/examples/project_blame.py @@ -1,10 +1,12 @@ import os from gitpandas import ProjectDirectory +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' if __name__ == '__main__': - g = ProjectDirectory(working_dir=os.path.abspath('../')) + g = ProjectDirectory(working_dir=GIT_PANDAS_DIR) b = g.blame(include_globs=['*.py'], ignore_globs=['lib/*', 'docs/*'], by='file') print(b.head(5)) diff --git a/examples/punchcard.py b/examples/punchcard.py index bb6bb6c..b464143 100644 --- a/examples/punchcard.py +++ b/examples/punchcard.py @@ -5,7 +5,9 @@ from gitpandas.utilities.plotting import plot_punchcard from gitpandas import ProjectDirectory -g = ProjectDirectory(working_dir=[...], verbose=True) +from definitions import GIT_PANDAS_DIR + +g = ProjectDirectory(working_dir=[str(GIT_PANDAS_DIR)], verbose=True) by = None punchcard = g.punchcard(branch='master', include_globs=['*.py'], by=by, normalize=2500) diff --git a/examples/repo_file_detail.py b/examples/repo_file_detail.py index 810b6c4..6a0715c 100644 --- a/examples/repo_file_detail.py +++ b/examples/repo_file_detail.py @@ -1,10 +1,12 @@ import os from gitpandas import ProjectDirectory +from definitions import GIT_PANDAS_DIR + __author__ = 'willmcginnis' if __name__ == '__main__': - g = ProjectDirectory(working_dir=os.path.abspath('../')) + g = ProjectDirectory(working_dir=GIT_PANDAS_DIR) b = g.file_detail(include_globs=['*.py'], ignore_globs=['lib/*', 'docs/*']) print(b.head(25)) diff --git a/gitpandas/project.py b/gitpandas/project.py index f7e7e31..08ce975 100644 --- a/gitpandas/project.py +++ b/gitpandas/project.py @@ -395,7 +395,7 @@ def file_detail(self, rev='HEAD', committer=True, ignore_globs=None, include_glo except GitCommandError: print('Warning! Repo: %s couldnt be inspected' % (repo, )) - df = df.reset_index(level=1) + df = df.reset_index(level=-1) df = df.set_index(['file', 'repository']) return df diff --git a/gitpandas/repository.py b/gitpandas/repository.py index d096531..9cbc53a 100644 --- a/gitpandas/repository.py +++ b/gitpandas/repository.py @@ -920,13 +920,13 @@ def file_detail(self, include_globs=None, ignore_globs=None, rev='HEAD', committ committer=committer, by='file' ) - blame = blame.reset_index(level=1) - blame = blame.reset_index(level=1) + blame = blame.reset_index(level=-1) + blame = blame.reset_index(level=-1) # reduce it to files and total LOC df = blame.reindex(columns=['file', 'loc']) df = df.groupby('file').agg({'loc': np.sum}) - df = df.reset_index(level=1) + df = df.reset_index(level=-1) # map in file owners df['file_owner'] = df['file'].map(lambda x: self.file_owner(rev, x, committer=committer)) diff --git a/gitpandas/utilities/plotting.py b/gitpandas/utilities/plotting.py index 421258b..456bcbd 100644 --- a/gitpandas/utilities/plotting.py +++ b/gitpandas/utilities/plotting.py @@ -43,7 +43,7 @@ def plot_punchcard(df, metric='lines', title='punchcard', by=None): else: sub_df = df fig = plt.figure(figsize=(8, title and 3 or 2.5), facecolor='#ffffff') - ax = fig.add_subplot('111', facecolor='#ffffff') + ax = fig.add_subplot(111, facecolor='#ffffff') fig.subplots_adjust(left=0.06, bottom=0.04, right=0.98, top=0.95) if by is not None: ax.set_title(title + ' (%s)' % (str(val), ), y=0.96).set_color('#333333') diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..f34029b --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +-e .[examples] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e41f13d..65307b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,2 @@ # Bare Minimum, to run tests add nose, to run some examples, add matplotlib -gitpython>=1.0.0 -numpy>=1.9.0 -pandas>=0.16.0 -requests -redis \ No newline at end of file +-e . \ No newline at end of file diff --git a/setup.py b/setup.py index ad2f5d5..cc0a670 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,12 @@ install_requires=[ 'gitpython>=1.0.0', 'numpy>=1.9.0', - 'pandas>=0.16.0' + 'pandas>=0.16.0', + 'requests', + 'redis' ], + extras_require={ + 'examples': ['matplotlib', 'lifelines'], + }, author_email='will@pedalwrencher.com' ) \ No newline at end of file