def test_from_xml_from_json_and_aggregation(self): ref_path, dis_path, asset, asset_original = set_default_576_324_videos_for_testing( ) asset_list = [asset, asset_original] self.runner = VmafQualityRunner( asset_list, None, fifo_mode=True, delete_workdir=True, result_store=None, optional_dict={ 'model_filepath': VmafConfig.model_path("vmaf_float_v0.6.1.pkl"), }, optional_dict2=None, ) self.runner.run() results = self.runner.results xml_string_expected = results[0].to_xml() xml_string_recon = Result.from_xml(xml_string_expected).to_xml() json_string_expected = results[0].to_json() json_string_recon = Result.from_json(json_string_expected).to_json() assert xml_string_expected == xml_string_recon, "XML files do not match" assert json_string_expected == json_string_recon, "JSON files do not match" combined_result = Result.combine_result([results[0], results[1]]) # check that all keys are there combined_result_keys = [key for key in combined_result.result_dict] keys_0 = [key for key in results[0].result_dict] keys_1 = [key for key in results[1].result_dict] assert set(keys_0) == set(keys_1) == set(combined_result_keys) # check that the dictionaries have been copied as expected for key in combined_result_keys: assert len(combined_result.result_dict[key]) == len( results[0].result_dict[key]) + len(results[1].result_dict[key]) assert combined_result.result_dict[key][0] == results[ 0].result_dict[key][0] assert combined_result.result_dict[key][ len(results[0].result_dict[key]) - 1] == results[0].result_dict[key][ len(results[0].result_dict[key]) - 1] assert combined_result.result_dict[key][len( results[0].result_dict[key])] == results[1].result_dict[key][0] assert combined_result.result_dict[key][ len(combined_result.result_dict[key]) - 1] == results[1].result_dict[key][ len(results[1].result_dict[key]) - 1]
def assemble(self): """ Main file assembly logic """ to_assemble_list = self.create_assembly_file_list(self.to_assemble_input) self._assert(to_assemble_list) results = self._create_result_list(to_assemble_list) combined_result = Result.combine_result(results) return combined_result