Skip to content

Commit

Permalink
Merge pull request #214 from vmarkovtsev/master
Browse files Browse the repository at this point in the history
Add labours.py --start-date and --end-date
  • Loading branch information
vmarkovtsev authored Feb 25, 2019
2 parents b15a7f7 + 4691049 commit 7ef5c47
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
32 changes: 28 additions & 4 deletions labours.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def parse_args():
"\"month\", \"year\", \"no\", \"raw\" and pandas offset aliases ("
"http://pandas.pydata.org/pandas-docs/stable/timeseries.html"
"#offset-aliases).")
dateutil_url = "https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.parse"
parser.add_argument("--start-date",
help="Start date of time-based plots. Any format is accepted which is "
"supported by %s" % dateutil_url)
parser.add_argument("--end-date",
help="End date of time-based plots. Any format is accepted which is "
"supported by %s" % dateutil_url)
parser.add_argument("--disable-projector", action="store_true",
help="Do not run Tensorflow Projector on couples.")
parser.add_argument("--max-people", default=20, type=int,
Expand Down Expand Up @@ -385,7 +392,15 @@ def read_input(args):
sys.stdout.flush()
if args.input != "-":
if args.input_format == "auto":
args.input_format = args.input.rsplit(".", 1)[1]
try:
args.input_format = args.input.rsplit(".", 1)[1]
except IndexError:
try:
with open(args.input) as f:
f.read(1 << 16)
args.input_format = "yaml"
except UnicodeDecodeError:
args.input_format = "pb"
elif args.input_format == "auto":
args.input_format = "yaml"
reader = READERS[args.input_format]()
Expand Down Expand Up @@ -745,6 +760,13 @@ def default_json(x):
return x


def parse_date(text, default):
if not text:
return default
from dateutil.parser import parse
return parse(text)


def plot_burndown(args, target, name, matrix, date_range_sampling, labels, granularity,
sampling, resample):
if args.output and args.output.endswith(".json"):
Expand Down Expand Up @@ -776,7 +798,8 @@ def plot_burndown(args, target, name, matrix, date_range_sampling, labels, granu
pyplot.xlabel("Time")
apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.background,
args.font_size, args.size)
pyplot.xlim(date_range_sampling[0], date_range_sampling[-1])
pyplot.xlim(parse_date(args.start_date, date_range_sampling[0]),
parse_date(args.end_date, date_range_sampling[-1]))
locator = pyplot.gca().xaxis.get_major_locator()
# set the optimal xticks locator
if "M" not in resample:
Expand Down Expand Up @@ -898,7 +921,8 @@ def plot_ownership(args, repo, names, people, date_range, last):
matplotlib, pyplot = import_pyplot(args.backend, args.style)

pyplot.stackplot(date_range, people, labels=names)
pyplot.xlim(date_range[0], last)
pyplot.xlim(parse_date(args.start_date, date_range[0]), parse_date(args.end_date, last))

if args.relative:
for i in range(people.shape[1]):
people[:, i] /= people[:, i].sum()
Expand Down Expand Up @@ -1165,7 +1189,7 @@ def show_sentiment_stats(args, name, resample, start_date, data):
pyplot.xlabel("Time")
apply_plot_style(pyplot.gcf(), pyplot.gca(), legend, args.background,
args.font_size, args.size)
pyplot.xlim(xdates[0], xdates[-1])
pyplot.xlim(parse_date(args.start_date, xdates[0]), parse_date(args.end_date, xdates[-1]))
locator = pyplot.gca().xaxis.get_major_locator()
# set the optimal xticks locator
if "M" not in resample:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ munch>=2.0
hdbscan==0.8.18
ortools==6.9.5824
fastdtw==0.3.2
python-dateutil==2.8.0

0 comments on commit 7ef5c47

Please sign in to comment.