Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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'] = \
results_recent[-1].relay_average_bandwidth
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(
results_recent)
kwargs['desc_bw_avg'] = \
cls.desc_bw_avg_from_results(results_recent)
kwargs['desc_bw_obs_last'] = \
cls.desc_bw_obs_last_from_results(results_recent)
kwargs['desc_bw_obs_mean'] = \
......@@ -419,6 +419,14 @@ class V3BWLine(object):
for rt in _ResultType])
return rt_dict
@staticmethod
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
@staticmethod
def desc_bw_obs_mean_from_results(results):
desc_bw_obs_ls = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment