Commit 9f517b90 authored by Eva Schiffer's avatar Eva Schiffer
Browse files

hooking up all the pass/fail details for two input stats so it will respect config file settings

parent 7497b180
......@@ -1201,10 +1201,14 @@ def stats_two_inputs_library_call(afn, bfn, var_list=None,
# extract some values to use later
default_epsilon = defaultValues[EPSILON_KEY] if EPSILON_KEY in defaultValues else None
# TODO, epsilon percent?
default_epsilon_percent = defaultValues[EPSILON_PERCENT_KEY] if EPSILON_PERCENT_KEY in defaultValues else None
default_fillval = defaultValues[FILL_VALUE_KEY] if FILL_VALUE_KEY in defaultValues else None
# TODO, failure tolerances?
default_epsilon_fail_tolerance = defaultValues[EPSILON_FAIL_TOLERANCE_KEY] if EPSILON_FAIL_TOLERANCE_KEY in defaultValues else None
default_nonfinite_tolerance = defaultValues[NONFINITE_TOLERANCE_KEY] if NONFINITE_TOLERANCE_KEY in defaultValues else None
default_total_fail_tolerance = defaultValues[TOTAL_FAIL_TOLERANCE_KEY] if TOTAL_FAIL_TOLERANCE_KEY in defaultValues else None
default_min_r_squared_coeff = defaultValues[MIN_OK_R_SQUARED_COEFF_KEY] if MIN_OK_R_SQUARED_COEFF_KEY in defaultValues else None
do_pass_fail = options_set[DO_TEST_PASSFAIL_KEY]
has_failed = False # for keeping track of if each variable comparison failed
warn_missing = options_set[OPTIONS_WARN_MISSING_KEY] if OPTIONS_WARN_MISSING_KEY in options_set else False
# open the files
......@@ -1225,12 +1229,6 @@ def stats_two_inputs_library_call(afn, bfn, var_list=None,
if usedConfigFile :
print("Configuration file: " + options_set[OPTIONS_CONFIG_FILE_KEY], file=output_channel, )
# information for testing pass/fail if needed
has_failed = False
# TODO, remove after we load these elsewhere
epsilon_fail_tolerance = 0.0
nonfinite_fail_tolerance = 0.0
# if we have command line input, we still need to parse the variable names
if not usedConfigFile:
temp_names = config_organizer.parse_varnames(common_variable_names, requestedNames,
......@@ -1318,24 +1316,51 @@ def stats_two_inputs_library_call(afn, bfn, var_list=None,
temp_epsilon = requestedNames[display_name][EPSILON_KEY] if EPSILON_KEY in requestedNames[display_name] \
else default_epsilon
temp_epsilon_percent = requestedNames[display_name][EPSILON_PERCENT_KEY] if EPSILON_PERCENT_KEY in requestedNames[display_name] \
else default_epsilon_percent
LOG.debug('comparing %s with epsilon %s and missing %s,%s' % (explain_name,temp_epsilon,amiss,bmiss))
print('-'*32, file=output_channel,)
print(explain_name, file=output_channel,)
print('', file=output_channel,)
variable_stats = statistics.StatisticalAnalysis.withSimpleData(aData, bData, amiss, bmiss, epsilon=temp_epsilon)
variable_stats = statistics.StatisticalAnalysis.withSimpleData(aData, bData,
amiss, bmiss,
epsilon=temp_epsilon,
epsilon_percent=temp_epsilon_percent,)
# if we're doing pass/fail testing, do that now
if do_pass_fail : # TODO, this is probably not right now that we may have better defaults
if do_pass_fail :
tempDefaults = config_organizer.get_simple_variable_defaults()
didPass, _, _, _ = variable_stats.check_pass_or_fail(epsilon_failure_tolerance=epsilon_fail_tolerance,
epsilon_failure_tolerance_default=tempDefaults[EPSILON_FAIL_TOLERANCE_KEY],
non_finite_data_tolerance=nonfinite_fail_tolerance,
non_finite_data_tolerance_default=tempDefaults[NONFINITE_TOLERANCE_KEY],
total_data_failure_tolerance_default=tempDefaults[TOTAL_FAIL_TOLERANCE_KEY],
min_acceptable_r_squared_default=tempDefaults[MIN_OK_R_SQUARED_COEFF_KEY],
)
# if there are values for how to check the pass/fail of our specific variable, pull those out
temp_epsilon_fail_tolerance = requestedNames[display_name][
EPSILON_FAIL_TOLERANCE_KEY] if EPSILON_FAIL_TOLERANCE_KEY in requestedNames[display_name] \
else numpy.nan
temp_nonfinite_tolerance = requestedNames[display_name][
NONFINITE_TOLERANCE_KEY] if NONFINITE_TOLERANCE_KEY in requestedNames[display_name] \
else numpy.nan
temp_total_fail_tolerance = requestedNames[display_name][
TOTAL_FAIL_TOLERANCE_KEY] if TOTAL_FAIL_TOLERANCE_KEY in requestedNames[display_name] \
else numpy.nan
temp_min_r_squared_coeff = requestedNames[display_name][
MIN_OK_R_SQUARED_COEFF_KEY] if MIN_OK_R_SQUARED_COEFF_KEY in requestedNames[display_name] \
else numpy.nan
# did we passs comparison?
didPass, _, _, _ = \
variable_stats.check_pass_or_fail(epsilon_failure_tolerance=temp_epsilon_fail_tolerance,
epsilon_failure_tolerance_default=default_epsilon_fail_tolerance,
non_finite_data_tolerance=temp_nonfinite_tolerance,
non_finite_data_tolerance_default=default_nonfinite_tolerance,
total_data_failure_tolerance=temp_total_fail_tolerance,
total_data_failure_tolerance_default=default_total_fail_tolerance,
min_acceptable_r_squared=temp_min_r_squared_coeff,
min_acceptable_r_squared_default=default_min_r_squared_coeff,
)
has_failed = has_failed or (not didPass)
message = explain_name + " has "
message += "failed comparison." if not didPass else "passed comparison."
LOG.debug(message)
lal = list(variable_stats.dictionary_form().items())
#lal = list(statistics.summarize(aData, bData, epsilon, (amiss,bmiss)).items())
lal.sort()
......@@ -1350,15 +1375,11 @@ def stats_two_inputs_library_call(afn, bfn, var_list=None,
print(('\n\n' + statistics.get_comparison_doc_string()), file=output_channel,)
# if we are doing pass/fail, we need to return a status code
status_code = 0
if do_pass_fail :
status_code = 0
if has_failed :
status_code = 3
LOG.debug("stats is returning status code: " + str(status_code))
return status_code
# note: if we aren't doing pass/fail, stats will return zero
return 0
status_code = 0 if not has_failed else 3
LOG.debug("stats is returning status code: " + str(status_code))
return status_code # note: if we aren't doing pass/fail, stats will return zero
def stats_one_input_library_call (afn, var_list=None, options_set=None, do_document=False,
output_channel=sys.stdout):
......
Supports Markdown
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