frag_pele/Growing/bestStructs.py
def parse_values(reports, n_structs, criteria, sort_order, steps):
    """

       Description: Parse the 'reports' and create a sorted array
       of size n_structs following the criteria chosen by the user.

    """

    INITIAL_DATA = [(DIR, []),
                    (REPORT, []),
                    (steps, []),
                    (criteria, [])
                    ]
    min_values = pd.DataFrame.from_dict(dict(INITIAL_DATA))
    for f in reports:
        report_number = os.path.basename(f).split("_")[-1]
        data = pd.read_csv(f, sep='    ', engine='python')
        # Skip first line not to get initial structure
        if not steps in list(data): steps="AcceptedSteps"
        selected_data = data.loc[1:, [steps, criteria]]
        if sort_order == "min":
                report_values =  selected_data.nsmallest(n_structs, criteria)
                report_values.insert(0, DIR, [f]*report_values[criteria].size)
                report_values.insert(1, REPORT, [report_number]*report_values[criteria].size)
                mixed_values = pd.concat([min_values, report_values])
                mixed_values.index = pd.RangeIndex(len(mixed_values.index))
                min_values = mixed_values.nsmallest(n_structs, criteria)

        else:
                report_values =  selected_data.nlargest(n_structs, criteria)
                report_values.insert(0, DIR, [f]*report_values[criteria].size)
                report_values.insert(1, REPORT, [report_number]*report_values[criteria].size)
                mixed_values = pd.concat([min_values, report_values])
                min_values = mixed_values.nlargest(n_structs, criteria)
    return min_values, steps


       Description: Parse the 'reports' and create a sorted array
       of size n_structs following the criteria chosen by the user.

    
Parse the 'reports' and create a sorted array
of size n_structs following the criteria chosen by the user.
Parse the ' reports ' and create a sorted array of size n_structs following the criteria chosen by the user .
def parse_values(reports, n_structs, criteria, sort_order, steps):
    INITIAL_DATA = [(DIR, []),
                    (REPORT, []),
                    (steps, []),
                    (criteria, [])
                    ]
    min_values = pd.DataFrame.from_dict(dict(INITIAL_DATA))
    for f in reports:
        report_number = os.path.basename(f).split("_")[-1]
        data = pd.read_csv(f, sep='    ', engine='python')
        if not steps in list(data): steps="AcceptedSteps"
        selected_data = data.loc[1:, [steps, criteria]]
        if sort_order == "min":
                report_values =  selected_data.nsmallest(n_structs, criteria)
                report_values.insert(0, DIR, [f]*report_values[criteria].size)
                report_values.insert(1, REPORT, [report_number]*report_values[criteria].size)
                mixed_values = pd.concat([min_values, report_values])
                mixed_values.index = pd.RangeIndex(len(mixed_values.index))
                min_values = mixed_values.nsmallest(n_structs, criteria)
        else:
                report_values =  selected_data.nlargest(n_structs, criteria)
                report_values.insert(0, DIR, [f]*report_values[criteria].size)
                report_values.insert(1, REPORT, [report_number]*report_values[criteria].size)
                mixed_values = pd.concat([min_values, report_values])
                min_values = mixed_values.nlargest(n_structs, criteria)
    return min_values, steps
def parse_values ( reports , n_structs , criteria , sort_order , steps ) : INITIAL_DATA = [ ( DIR , [ ] ) , ( REPORT , [ ] ) , ( steps , [ ] ) , ( criteria , [ ] ) ] min_values = pd . DataFrame . from_dict ( dict ( INITIAL_DATA ) ) for f in reports : report_number = os . path . basename ( f ) . split ( "_" ) [ - 1 ] data = pd . read_csv ( f , sep = '    ' , engine = 'python' ) if not steps in list ( data ) : steps = "AcceptedSteps" selected_data = data . loc [ 1 : , [ steps , criteria ] ] if sort_order == "min" : report_values = selected_data . nsmallest ( n_structs , criteria ) report_values . insert ( 0 , DIR , [ f ] * report_values [ criteria ] . size ) report_values . insert ( 1 , REPORT , [ report_number ] * report_values [ criteria ] . size ) mixed_values = pd . concat ( [ min_values , report_values ] ) mixed_values . index = pd . RangeIndex ( len ( mixed_values . index ) ) min_values = mixed_values . nsmallest ( n_structs , criteria ) else : report_values = selected_data . nlargest ( n_structs , criteria ) report_values . insert ( 0 , DIR , [ f ] * report_values [ criteria ] . size ) report_values . insert ( 1 , REPORT , [ report_number ] * report_values [ criteria ] . size ) mixed_values = pd . concat ( [ min_values , report_values ] ) min_values = mixed_values . nlargest ( n_structs , criteria ) return min_values , steps
Description: Parse the 'reports' and create a sorted array
of size n_structs following the criteria chosen by the user.
Description : Parse the ' reports ' and create a sorted array of size n_structs following the criteria chosen by the user .
"""

       Description: Parse the 'reports' and create a sorted array
       of size n_structs following the criteria chosen by the user.

    """ # Skip first line not to get initial structure
reports
n_structs
criteria
sort_order
steps