Skip to content

Commit

Permalink
Fixing up places where YAPF formatted weirdly, mostly in docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Oct 1, 2015
1 parent d199ecc commit bd85dd5
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 510 deletions.
214 changes: 107 additions & 107 deletions convert_from_telescope/aggregate.py
Expand Up @@ -30,21 +30,21 @@
def aggregate_by_month(results):
"""Aggregate test results by month.
Args:
results: (list) A list of 2-tuples where the first entry is a datetime and
the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to midnight on the first day of the month. For example:
{
<datetime-2014-10-01@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-11-01@00:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-12-01@00:00:00>: [18.0, 19.8, 97.6, ...],
...
}
"""
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to midnight on the first day of the month. For example:
{
<datetime-2014-10-01@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-11-01@00:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-12-01@00:00:00>: [18.0, 19.8, 97.6, ...],
...
}
"""
aggregation_func = lambda result_datetime: (
datetime.datetime(year=result_datetime.year,
month=result_datetime.month,
Expand All @@ -55,21 +55,21 @@ def aggregate_by_month(results):
def aggregate_by_day(results):
"""Aggregate test results by day.
Args:
results: (list) A list of 2-tuples where the first entry is a datetime and
the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to midnight of the given day. For example:
{
<datetime-2014-10-16@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-17@00:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-25@00:00:00>: [18.0, 19.8, 97.6, ...],
...
}
"""
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to midnight of the given day. For example:
{
<datetime-2014-10-16@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-17@00:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-25@00:00:00>: [18.0, 19.8, 97.6, ...],
...
}
"""
aggregation_func = lambda result_datetime: (
datetime.datetime(year=result_datetime.year,
month=result_datetime.month,
Expand All @@ -80,56 +80,56 @@ def aggregate_by_day(results):
def aggregate_by_hour_of_day(results):
"""Aggregate test results by hour of day.
Aggregate together all tests that occur in the same hour of day (e.g. all
results from 2-3 PM are aggregated together, even if the results occurred on
different days). Note that this differs from the aggregate_by_hour function.
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by int. Each key is the hour in
which a result occurred (in the range 0...23). For example:
{
0: [24.1, 35.8, 16.6, ...],
1: [92.2, 100.3, 23.0, ...],
2: [18.0, 19.8, 97.6, ...],
...
}
"""
Aggregate together all tests that occur in the same hour of day (e.g. all
results from 2-3 PM are aggregated together, even if the results occurred on
different days). Note that this differs from the aggregate_by_hour function.
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by int. Each key is the hour in
which a result occurred (in the range 0...23). For example:
{
0: [24.1, 35.8, 16.6, ...],
1: [92.2, 100.3, 23.0, ...],
2: [18.0, 19.8, 97.6, ...],
...
}
"""
aggregation_func = lambda result_datetime: result_datetime.hour
return _aggregate_results(results, aggregation_func)


def aggregate_by_hour_of_day_per_month(results):
"""Aggregate test results by hour of day for each month.
Aggregate together all tests each month that occur in the same hour of day
(e.g. all results from 2-3 PM in March 2014 are aggregated together, even if
they occurred on different days, while results from 2-3 PM in April 2014 are
aggregated separately from the March 2014 results).
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to the first day of the month and to the start of the hour. For
example:
{
<datetime-2014-10-01@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-01@01:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-01@02:00:00>: [18.2, 101.9, 9.2, ...],
...
<datetime-2014-11-01@00:00:00>: [14.2, 84.2, 23.5, ...],
<datetime-2014-11-01@01:00:00>: [86.3, 29.2, 18.0, ...],
...
}
"""
Aggregate together all tests each month that occur in the same hour of day
(e.g. all results from 2-3 PM in March 2014 are aggregated together, even if
they occurred on different days, while results from 2-3 PM in April 2014 are
aggregated separately from the March 2014 results).
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to the first day of the month and to the start of the hour. For
example:
{
<datetime-2014-10-01@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-01@01:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-01@02:00:00>: [18.2, 101.9, 9.2, ...],
...
<datetime-2014-11-01@00:00:00>: [14.2, 84.2, 23.5, ...],
<datetime-2014-11-01@01:00:00>: [86.3, 29.2, 18.0, ...],
...
}
"""
aggregation_func = lambda result_datetime: (
datetime.datetime(year=result_datetime.year,
month=result_datetime.month,
Expand All @@ -141,29 +141,29 @@ def aggregate_by_hour_of_day_per_month(results):
def aggregate_by_hour(results):
"""Aggregate test results by hour each day.
Aggregate test results by hour (e.g. all results from 2-3 PM on 2014/05/14
are aggregated together, all results from 3-4 PM on 2014/05/14 are
aggregated together).
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to the first day of the month and to the start of the hour. For
example:
{
<datetime-2014-10-12@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-12@01:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-12@02:00:00>: [18.2, 101.9, 9.2, ...],
...
<datetime-2014-11-03@00:00:00>: [14.2, 84.2, 23.5, ...],
<datetime-2014-11-03@01:00:00>: [86.3, 29.2, 18.0, ...],
...
}
"""
Aggregate test results by hour (e.g. all results from 2-3 PM on 2014/05/14
are aggregated together, all results from 3-4 PM on 2014/05/14 are
aggregated together).
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Returns:
(dict) A dictionary of lists, keyed by datetime. Each key is a datetime
rounded to the first day of the month and to the start of the hour. For
example:
{
<datetime-2014-10-12@00:00:00>: [24.1, 35.8, 16.6, ...],
<datetime-2014-10-12@01:00:00>: [92.2, 100.3, 23.0, ...],
<datetime-2014-10-12@02:00:00>: [18.2, 101.9, 9.2, ...],
...
<datetime-2014-11-03@00:00:00>: [14.2, 84.2, 23.5, ...],
<datetime-2014-11-03@01:00:00>: [86.3, 29.2, 18.0, ...],
...
}
"""
aggregation_func = lambda result_datetime: (
datetime.datetime(year=result_datetime.year,
month=result_datetime.month,
Expand All @@ -175,19 +175,19 @@ def aggregate_by_hour(results):
def _aggregate_results(results, aggregation_func):
"""Aggregate test results according to the given aggregation function.
Args:
results: (list) A list of 2-tuples where the first entry is a datetime and
the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
Args:
results: (list) A list of 2-tuples where the first entry is a datetime
and the second is a float. For example:
[(<datetime-2014-10-05>, 24.1), (<datetime-2014-11-02>, 90.2), ...]
aggregation_func: (function) An aggregation function responsible for
translating a datetime object into an aggregation key.
aggregation_func: (function) An aggregation function responsible for
translating a datetime object into an aggregation key.
Returns:
(dict) A dictionary of lists, where each list includes all results in that
aggregation unit (float values), keyed by whatever type aggregation_func
outputs as an aggregation key.
"""
Returns:
(dict) A dictionary of lists, where each list includes all results in
that aggregation unit (float values), keyed by whatever type
aggregation_func outputs as an aggregation key.
"""
aggregated_data = {}

for result_datetime, value in results:
Expand Down

0 comments on commit bd85dd5

Please sign in to comment.