From 934b39154cb0bda5d14517ab734117d10cd6bc06 Mon Sep 17 00:00:00 2001 From: Nagariku Date: Tue, 28 Mar 2023 00:32:29 +0200 Subject: [PATCH] Everything except simplified kripendorf working --- src/main.py | 4 ++-- src/methods/data_processing.py | 7 ++++--- src/methods/report_generator.py | 21 ++++++++------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main.py b/src/main.py index 1704cb5..a167edb 100644 --- a/src/main.py +++ b/src/main.py @@ -10,12 +10,12 @@ def main(): mainFolderPath,configFileMain,hashL, xlsxList = initialisation.main() levelListM,inputsSubListM, inputsDimListM, inputsInterDimensionalListM, kripSimplifiedListM=data_import.main(mainFolderPath,configFileMain, xlsxList) - outputDataframeMain, subDimConsistencyListMain, DimConsistencyListMain, DimWeightListMain,DimConsistencyListMain=data_processing.main(inputsSubListM, inputsDimListM) + outputDataframeMain, DimConsistencyListMain, DimWeightListMain=data_processing.main(inputsSubListM, inputsDimListM) from src.methods import report_generator # to make global variable work report_generator.main(mainFolderPath,configFileMain,len(xlsxList),levelListM,inputsSubListM, inputsDimListM, inputsInterDimensionalListM, kripSimplifiedListM,outputDataframeMain, - subDimConsistencyListMain, DimConsistencyListMain,DimWeightListMain) + DimConsistencyListMain,DimWeightListMain) logging.info("Program ended") logging.info("Program runtime: " + f"{(time.time() - start_time):.2f}" + " seconds") diff --git a/src/methods/data_processing.py b/src/methods/data_processing.py index d1a20a2..e137786 100644 --- a/src/methods/data_processing.py +++ b/src/methods/data_processing.py @@ -16,7 +16,7 @@ def main(subInputList,dimInputList): #matrix = matrix_make(data) #print(ahp(matrix,RI[matrix.shape[0]])) subDimListWeights, subDimConsistencyList = process_list_to_usable(subInputList) - DimWeightList,DimConsistencyList,colList = process_dataframe_to_usable(dimInputList) + DimWeightList,colList = process_dataframe_to_usable(dimInputList) outputList = multiply_weights(subDimListWeights,DimWeightList) outputCalcWeights= convert_to_dataframe(outputList,colList) @@ -25,9 +25,10 @@ def main(subInputList,dimInputList): outputConsistency = convert_to_dataframe(subDimConsistencyList,colList) #outputDimConsistency = convert_to_dataframe(DimConsistencyList,colList) + logging.info("M - Data processing finished successfully") - return outputCalcWeights,outputSubDimweights,outputConsistency, DimWeightList,DimConsistencyList + return outputCalcWeights,outputConsistency, DimWeightList def process_list_to_usable(uncutList): @@ -65,7 +66,7 @@ def process_dataframe_to_usable(uncutDataframe): - return workingListWeights, workingConsistencyIndexList, columnList + return workingListWeights, columnList def multiply_weights(sudDimWeights, dimWeights): finalList=[] diff --git a/src/methods/report_generator.py b/src/methods/report_generator.py index c651ee1..bd04fc6 100644 --- a/src/methods/report_generator.py +++ b/src/methods/report_generator.py @@ -11,7 +11,7 @@ ##############Main function############## def main(mFP,cFM,nList,levelListSM,weightListSM, dimensionListSM, interDimensionalListSM, kripSimplifiedListSM, outputDataframeSM, - subDimConsistencyListSM, DimConsistencyListSM,DimWeightListSM): + subDimConsistencyListSM,DimWeightListSM): logging.info("M - Report generation started") outFolderPath = check_output_folder(cFM.get("Settings", "outputFolder"),mFP) #check if output folder exists listDimension,combinedList=get_subsection(cFM) #get subsections and dimensions from config file @@ -23,7 +23,7 @@ def main(mFP,cFM,nList,levelListSM,weightListSM, dimensionListSM, csv_dim_inputs_pre(dimensionListSM,sOF) #generates csv file with dimensions inputs csv_interdim_comparisions_input(interDimensionalListSM,sOF) #generates csv file with interdimensional comparisions csv_calculated_weights(outputDataframeSM,sOF,combinedList,DimWeightListSM,listDimension) #generates csv file with calculated weights - + csv_consistency_indexes(subDimConsistencyListSM,sOF,listDimension) #generates csv file with consistency indexes logging.info("M - Report generation finished successfully") return None @@ -102,27 +102,22 @@ def csv_kripke_simplified(kSL,sOF): #doesn't work def csv_calculated_weights(df,sOF,combL,DimWeightListSMFunc,listDimensionFunc): data = {} - - # Loop through each array in the list and create a column name and add to the dictionary for i, array in enumerate(DimWeightListSMFunc): - column_name = 'col' + str(i + 1) # Create a column name for the array - data[column_name] = array # Add the array to the dictionary with its column name - - # Create a pandas dataframe using the dictionary + column_name = 'col' + str(i + 1) + data[column_name] = array dfDimension = pd.DataFrame(data) dfDimension.index=listDimensionFunc - - df.index=combL dfDimension.columns=df.columns - - finalout = pd.concat([dfDimension,df],axis=0) outPath=os.path.join(sOF, "Calculated_weights.csv") finalout.to_csv(outPath, index=True) return None -def csv_consistency_indexes(): +def csv_consistency_indexes(sDCL,sOF,listDimensionFunc): + sDCL.index=listDimensionFunc + outPath=os.path.join(sOF, "Consistency_indexes.csv") + sDCL.to_csv(outPath, index=True) return None