parameters_testing_utilities.py
def _show_data_in_jpg(data: dict,
                      file_name: str,
                      description: str = "classic") -> None:
    """
    Visualises the results in multiple graphs
    """

    for parameter in data.keys():
        elem = data[parameter]
        print("len - {}".format(len(elem.keys())))

        keys = []
        time_values = []
        error_values = []

        for key, value in elem.items():
            keys.append(float(key))
            time_values.append(float(value["time"]))
            error_values.append(float(value["error"]))

        fig, ax1 = plt.subplots()

        color = 'tab:blue'
        ax1.set_xlabel(parameter)
        ax1.set_ylabel('time [s]', color=color)
        ax1.plot(keys, time_values, color=color)
        ax1.tick_params(axis='y', labelcolor=color)

        ax2 = ax1.twinx()  # instantiate a second axes that shares the same x-axis

        color = 'tab:red'
        ax2.set_ylabel('error [-]', color=color)  # we already handled the x-label with ax1
        ax2.plot(keys, error_values, color=color)
        ax2.tick_params(axis='y', labelcolor=color)

        plt.title("Parameters testing {} - {}".format(description, parameter))

        plt.grid()

        fig.tight_layout()  # otherwise the right y-label is slightly clipped
        # plt.show()

        file_name_for_picture = "{}-{}.png".format(file_name.strip(".json"),
                                                   parameter)
        plt.savefig(file_name_for_picture)

        plt.clf()

    Visualises the results in multiple graphs
    
Visualises the results in multiple graphs
Visualises the results in multiple graphs
def _show_data_in_jpg(data: dict,
                      file_name: str,
                      description: str = "classic") -> None:
    for parameter in data.keys():
        elem = data[parameter]
        print("len - {}".format(len(elem.keys())))
        keys = []
        time_values = []
        error_values = []
        for key, value in elem.items():
            keys.append(float(key))
            time_values.append(float(value["time"]))
            error_values.append(float(value["error"]))
        fig, ax1 = plt.subplots()
        color = 'tab:blue'
        ax1.set_xlabel(parameter)
        ax1.set_ylabel('time [s]', color=color)
        ax1.plot(keys, time_values, color=color)
        ax1.tick_params(axis='y', labelcolor=color)
        ax2 = ax1.twinx()  
        color = 'tab:red'
        ax2.set_ylabel('error [-]', color=color)  
        ax2.plot(keys, error_values, color=color)
        ax2.tick_params(axis='y', labelcolor=color)
        plt.title("Parameters testing {} - {}".format(description, parameter))
        plt.grid()
        fig.tight_layout()  
        file_name_for_picture = "{}-{}.png".format(file_name.strip(".json"),
                                                   parameter)
        plt.savefig(file_name_for_picture)
        plt.clf()
def _show_data_in_jpg ( data : dict , file_name : str , description : str = "classic" ) -> None : for parameter in data . keys ( ) : elem = data [ parameter ] print ( "len - {}" . format ( len ( elem . keys ( ) ) ) ) keys = [ ] time_values = [ ] error_values = [ ] for key , value in elem . items ( ) : keys . append ( float ( key ) ) time_values . append ( float ( value [ "time" ] ) ) error_values . append ( float ( value [ "error" ] ) ) fig , ax1 = plt . subplots ( ) color = 'tab:blue' ax1 . set_xlabel ( parameter ) ax1 . set_ylabel ( 'time [s]' , color = color ) ax1 . plot ( keys , time_values , color = color ) ax1 . tick_params ( axis = 'y' , labelcolor = color ) ax2 = ax1 . twinx ( ) color = 'tab:red' ax2 . set_ylabel ( 'error [-]' , color = color ) ax2 . plot ( keys , error_values , color = color ) ax2 . tick_params ( axis = 'y' , labelcolor = color ) plt . title ( "Parameters testing {} - {}" . format ( description , parameter ) ) plt . grid ( ) fig . tight_layout ( ) file_name_for_picture = "{}-{}.png" . format ( file_name . strip ( ".json" ) , parameter ) plt . savefig ( file_name_for_picture ) plt . clf ( )
Visualises the results in multiple graphs
Visualises the results in multiple graphs
"""
    Visualises the results in multiple graphs
    """ # instantiate a second axes that shares the same x-axis # we already handled the x-label with ax1 # otherwise the right y-label is slightly clipped # plt.show()
data
dict
file_name
str
description
str