Skip to content

Fix all examples to run either from root or in examples dir #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions examples/commit_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
from pandas import set_option

from definitions import GIT_PANDAS_DIR

__author__ = 'willmcginnis'


Expand Down Expand Up @@ -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)
3 changes: 3 additions & 0 deletions examples/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pathlib import Path

GIT_PANDAS_DIR = Path(__file__).resolve().parent.parent
4 changes: 3 additions & 1 deletion examples/file_change_rates.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions examples/hours_estimate.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 3 additions & 1 deletion examples/parallel_blame.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 3 additions & 1 deletion examples/project_blame.py
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
4 changes: 3 additions & 1 deletion examples/punchcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion examples/repo_file_detail.py
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion gitpandas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions gitpandas/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion gitpandas/utilities/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e .[examples]
6 changes: 1 addition & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
-e .
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]'
)