def sap_from_yaml(fname): dwelling = yaml_io.from_yaml(fname) runner.run_sap(dwelling) runner.run_der(dwelling) epctk.appendix.appendix_t.run_ter(dwelling) runner.run_fee(dwelling) print_header("SAP RESULTS") print(dwelling.er_results.report) print_header("DER RESULTS") print(dwelling.der_results.report) print_header("TER RESULTS") print(dwelling.ter_results.report) print_header("FEE RESULTS") print(dwelling.fee_results.report)
def dwelling_from_file(fname, reparse): yaml_file = os.path.join(_FOLDER, "yaml_test_cases", os.path.basename(fname) + ".yml") if os.path.exists(yaml_file) and not reparse: dwelling = yaml_io.from_yaml(yaml_file) else: parsed_ref_case = load_reference_case(fname, reference_case_parser.whole_file, reparse) dwelling = create_sap_dwelling(parsed_ref_case.inputs) with open(yaml_file, 'w') as f: yaml_io.to_yaml(dwelling, f) output_checker.check_results(dwelling, parsed_ref_case) # FIXME Bit of a hack here because some of our tests case files don't include sap region if fname in SAP_REGIONS: dwelling['sap_region'] = SAP_REGIONS[os.path.basename(fname)] elif not dwelling.get("sap_region"): dwelling['sap_region'] = 11 return dwelling
def run_case(fname, reparse): logging.warning("RUNNING %s" % (fname,)) try: yaml_file = os.path.join(_FOLDER, "yaml_test_cases", os.path.basename(fname) + ".yml") if os.path.exists(yaml_file) and not reparse: dwelling = yaml_io.from_yaml(yaml_file) else: parsed_ref_case = load_reference_case(fname, reference_case_parser.whole_file, reparse) dwelling = create_sap_dwelling(parsed_ref_case.inputs) with open(yaml_file, 'w') as f: yaml_io.to_yaml(dwelling, f) output_checker.check_results(dwelling, parsed_ref_case) run_dwelling(fname, dwelling) except SAPCalculationError: # if output_checker.is_err_calc(parsed_ref_case): # return # else: raise logging.info("DONE")
def sap_from_yaml(fname): dwelling = yaml_io.from_yaml(fname) print_header("SAP RESULTS") sap_out = runner.run_sap(dwelling) print(sap_out.results) print_header("DER RESULTS") der_out = runner.run_der(dwelling) print(der_out.results) print_header("TER RESULTS") ter_out = epctk.appendix.appendix_t.run_ter(dwelling) print(ter_out.results) print_header("FEE RESULTS") fee_out = runner.run_fee(dwelling) print(fee_out.results)
def get_dwelling(fname, force_reparse): """ Get dwelling data, reparsing the raw input if no cache is found TODO: figure difference between dwelling and parsed output, at the moment have a bit of a hack by returning both together """ basename = os.path.basename(fname) pickled_fname = os.path.join("pickled_reference_cases", basename + ".pkl") yaml_fname = os.path.join("yaml_test_cases", basename + ".yml") if os.path.exists(pickled_fname) and not force_reparse: dwelling_data = pickle.load(open(pickled_fname, "r")) if os.path.exists(yaml_fname): # YAML load directly produces a dwelling, not dwelling data! dwelling = yaml_io.from_yaml(yaml_fname) else: dwelling = create_sap_dwelling(dwelling_data.inputs) with open(yaml_fname, 'w') as yaml_file: yaml_io.to_yaml(dwelling, yaml_file) else: print(("Reparsing ", fname)) dwelling_data = parse_file(fname) dwelling = create_sap_dwelling(dwelling_data.inputs) pickle.dump(dwelling_data, open(pickled_fname, "w")) with open(yaml_fname, 'w') as yaml_file: yaml_io.to_yaml(dwelling, yaml_file) # ! Append the SAP region for the cases where it doesn't exist add_sap_region(dwelling, fname) return dwelling_data, dwelling