def test_calculate_percent_error_calculates_correct_values(): tpms = _get_test_tpms() t.calculate_percent_error(tpms) for index, row in tpms.iterrows(): val = 100 * ((CALC_TPMS_VALS[index] - REAL_TPMS_VALS[index]) / float(REAL_TPMS_VALS[index])) npt.assert_approx_equal(row[t.PERCENT_ERROR], val)
def _get_test_tpms(): tpms = pd.DataFrame.from_dict({ t.REAL_TPM: test_tpms.REAL_TPMS_VALS, t.CALCULATED_TPM: test_tpms.CALC_TPMS_VALS, test_tpms.GROUP_TEST_COL: test_tpms.GROUPS }) t.calculate_log_ratios(tpms) t.calculate_percent_error(tpms) t.mark_positives_and_negatives(tpms) return tpms, t.get_true_positives(tpms)