Commit f3f0d49e authored by juga  's avatar juga
Browse files

v3bwfile: refactor, get desc_bw_avg from method

This way it can be obtained in a different way (for instance, the
mean, not the last) and it also avoids not obtaining any value in
case the last is None.
parent dca252ae
......@@ -327,8 +327,6 @@ class V3BWLine(object):
if not len(results_recent) >= min_num:
# log.debug('The number of results is less than %s', min_num)
return None
kwargs['desc_bw_avg'] = \
rtt = cls.rtt_from_results(results_recent)
if rtt:
kwargs['rtt'] = rtt
......@@ -336,6 +334,8 @@ class V3BWLine(object):
kwargs['bw_mean'] = cls.bw_mean_from_results(results_recent)
kwargs['bw_median'] = cls.bw_median_from_results(
kwargs['desc_bw_avg'] = \
kwargs['desc_bw_obs_last'] = \
kwargs['desc_bw_obs_mean'] = \
......@@ -419,6 +419,14 @@ class V3BWLine(object):
for rt in _ResultType])
return rt_dict
def desc_bw_avg_from_results(results):
"""Obtain the last descriptor bandwidth average from the results."""
for r in reversed(results):
if r.relay_average_bandwidth is not None:
return r.relay_average_bandwidth
return None
def desc_bw_obs_mean_from_results(results):
desc_bw_obs_ls = []
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment