Commit e3b4c4ed authored by juga  's avatar juga
Browse files

fix: tests: Add bw filtered from results

parent cc343eb8
"""Unit tests for scaling.py."""
import os
from statistics import mean
from sbws.lib import scaling
from sbws.lib.resultdump import load_result_file, ResultSuccess
def test_bw_filt():
......@@ -38,3 +40,30 @@ def test_bw_filt():
assert 10 == round(mean(bw_measurements))
# Because 10 and 20 are bigger or equal than the mean
assert 15 == scaling.bw_filt(bw_measurements)
def test_bw_filt_from_results(root_data_path):
results_file = os.path.join(
root_data_path, ".sbws", "datadir", "2019-03-25.txt"
)
results = load_result_file(results_file)
bw_filts = {}
for fp, values in results.items():
success_results = [r for r in values if isinstance(r, ResultSuccess)]
if success_results:
bw_measurements = scaling.bw_measurements_from_results(
success_results
)
mu = round(mean(bw_measurements))
muf = scaling.bw_filt(bw_measurements)
bw_filts[fp] = (mu, muf)
for fp, values in bw_filts.items():
assert bw_filts[fp][0] <= bw_filts[fp][1]
assert 5526756 == bw_filts['117A456C911114076BEB4E757AC48B16CC0CCC5F'][0]
assert 5643086 == bw_filts['117A456C911114076BEB4E757AC48B16CC0CCC5F'][1]
assert 5664965 == bw_filts['693F73187624BE760AAD2A12C5ED89DB1DE044F5'][0]
assert 5774274 == bw_filts['693F73187624BE760AAD2A12C5ED89DB1DE044F5'][1]
assert 5508279 == bw_filts['270A861ABED22EC2B625198BCCD7B2B9DBFFC93C'][0]
assert 5583737 == bw_filts['270A861ABED22EC2B625198BCCD7B2B9DBFFC93C'][1]
assert 5379911 == bw_filts['E894C65997F8EC96558B554176EEEA39C6A43EF6'][0]
assert 5485088 == bw_filts['E894C65997F8EC96558B554176EEEA39C6A43EF6'][1]
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