CellModules
|
Public Member Functions | |
def | __init__ (self, str db_filename) |
def | open (self) |
def | close (self) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_val, exc_tb) |
def | add_conditions (self, pd.DataFrame conditions_df, str id_column=None) |
def | add_error (self, pd.DataFrame data_df) |
def | add_parameters (self, list parameters_list) |
def | add_data (self, str table_name, pd.DataFrame data_df) |
pd.DataFrame | get (self, str table, str filter_conditions=None) |
pd.DataFrame | getBestScore (self, str errorName, int n=1, bool forEachCondition=False) |
pd.DataFrame | getBest (self, str table, str errorName, int n=1, bool forEachCondition=False) |
pd.DataFrame | getByID (self, str table, int ID_PARAMETER=None, int ID_CONDITION=None) |
pd.DataFrame | getPareto (self, list errorNameList, bool forEachCondition=False) |
pd.DataFrame | __getitem__ (self, str table) |
str | summarize (self) |
str | __str__ (self) |
Public Attributes | |
db_filename | |
conn | |
Manager for interacting with a SQLite database. This class provides methods to add data, query data, and manage tables in the database. Parameters ---------- - **db_filename** : str The filename of the SQLite database. Methods ------- - **add_conditions** : Adds a DataFrame of conditions to the 'condition' table in the database. - **add_parameters** : Adds a list of parameters to the 'parameters' table in the database. - **add_data** : Adds a DataFrame of data to a specified table in the database. - **add_error** : Adds a DataFrame of error data to the 'error' table in the database. - **get** : Retrieves records from a table based on filter conditions. - **getByID** : Retrieves records from a table based on ID_PARAMETER and/or ID_CONDITION. - **getPareto** : Retrieves the Pareto front for given errors. - **getBestScore** : Retrieves the best scores for a given error. - **getBest** : Retrieves the best records from a table based on a given error. - **summarize** : Returns a summary of the database. Example ------- ```python conditions = pd.DataFrame([ [0.5, 1], [0.2, 2], [0.2, 5] ], columns=['info1', 'info2']) parameters_list = LHSIterator(param,10) with DatabaseManager("example.db") as db: db.add_parameters(parameters_list) db.add_conditions(conditions) for states,other in MultiSimu(run_simu,parameters_list,conditions=conditions.values.tolist(),replicat=5,withTqdm=True,batch_size_level='param'): db.add_data('states', states.reset_index()) db.add_data('otherData', other.reset_index()) error = your_error_function(states) db.add_error(error) ```
Definition at line 6 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.__init__ | ( | self, | |
str | db_filename | ||
) |
Definition at line 50 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.__enter__ | ( | self | ) |
Definition at line 67 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.__exit__ | ( | self, | |
exc_type, | |||
exc_val, | |||
exc_tb | |||
) |
Definition at line 71 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.__getitem__ | ( | self, | |
str | table | ||
) |
Definition at line 413 of file DatabaseManager.py.
str pythonlib.DatabaseManager.DatabaseManager.__str__ | ( | self | ) |
Definition at line 438 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.add_conditions | ( | self, | |
pd.DataFrame | conditions_df, | ||
str | id_column = None |
||
) |
Adds a DataFrame of conditions to the 'condition' table in the database. Parameters ---------- - **conditions_df** : pd.DataFrame The DataFrame containing the conditions to add. - **id_column** : str, optional The column to use as the ID_CONDITION. If not provided, the index will be used.
Definition at line 74 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.add_data | ( | self, | |
str | table_name, | ||
pd.DataFrame | data_df | ||
) |
Adds a DataFrame of data to a specified table in the database. Parameters ---------- - **table_name** : str The name of the table to add data to. - **data_df** : pd.DataFrame The DataFrame containing the data to add.
Definition at line 129 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.add_error | ( | self, | |
pd.DataFrame | data_df | ||
) |
Adds a DataFrame of error data to the 'error' table in the database. Parameters ---------- - **data_df** : pd.DataFrame The DataFrame containing the error data to add.
Definition at line 97 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.add_parameters | ( | self, | |
list | parameters_list | ||
) |
Adds a list of parameters to the 'parameters' table in the database. Parameters ---------- - **parameters_list** : list The list of parameters to add.
Definition at line 113 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.close | ( | self | ) |
Closes the connection to the database.
Definition at line 61 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.get | ( | self, | |
str | table, | ||
str | filter_conditions = None |
||
) |
Retrieves records from a table based on filter conditions. Parameters ---------- - **table** : str The name of the table to retrieve records from. - **filter_conditions** : str, optional The SQL filter conditions to apply. Returns ------- - **pd.DataFrame** : The DataFrame containing the retrieved records.
Definition at line 148 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.getBest | ( | self, | |
str | table, | ||
str | errorName, | ||
int | n = 1 , |
||
bool | forEachCondition = False |
||
) |
Retrieves the best records from a table based on a given error. Parameters ---------- - **table** : str The name of the table to retrieve records from. - **errorName** : str The name of the error column to base the records on. - **n** : int, optional The number of top records to retrieve. - **forEachCondition** : bool, optional Whether to retrieve the best records for each condition separately. Returns ------- - **pd.DataFrame** : The DataFrame containing the best records.
Definition at line 274 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.getBestScore | ( | self, | |
str | errorName, | ||
int | n = 1 , |
||
bool | forEachCondition = False |
||
) |
Retrieves the best scores for a given error. Parameters ---------- - **errorName** : str The name of the error column to base the scores on. - **n** : int, optional The number of top scores to retrieve. - **forEachCondition** : bool, optional Whether to retrieve the best scores for each condition separately. Returns ------- - **pd.DataFrame** : The DataFrame containing the best scores.
Definition at line 233 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.getByID | ( | self, | |
str | table, | ||
int | ID_PARAMETER = None , |
||
int | ID_CONDITION = None |
||
) |
Retrieves records from a table based on ID_PARAMETER and/or ID_CONDITION. Parameters ---------- - **table** : str The name of the table to retrieve records from. - **ID_PARAMETER** : int, optional The ID_PARAMETER to filter by. - **ID_CONDITION** : int, optional The ID_CONDITION to filter by. Returns ------- - **pd.DataFrame** : The DataFrame containing the retrieved records.
Definition at line 323 of file DatabaseManager.py.
pd.DataFrame pythonlib.DatabaseManager.DatabaseManager.getPareto | ( | self, | |
list | errorNameList, | ||
bool | forEachCondition = False |
||
) |
Retrieves the Pareto front for given errors. Parameters ---------- - **errorNameList** : list The list of error column names to consider. - **forEachCondition** : bool, optional Whether to retrieve the Pareto front for each condition separately. Returns ------- - **pd.DataFrame** : The DataFrame containing the Pareto front.
Definition at line 359 of file DatabaseManager.py.
def pythonlib.DatabaseManager.DatabaseManager.open | ( | self | ) |
Opens a connection to the database.
Definition at line 53 of file DatabaseManager.py.
str pythonlib.DatabaseManager.DatabaseManager.summarize | ( | self | ) |
Returns a summary of the database. Returns ------- - **str** : The summary of the database.
Definition at line 418 of file DatabaseManager.py.
pythonlib.DatabaseManager.DatabaseManager.conn |
Definition at line 57 of file DatabaseManager.py.
pythonlib.DatabaseManager.DatabaseManager.db_filename |
Definition at line 51 of file DatabaseManager.py.