aequilibrae.project.data#

class aequilibrae.project.data.Matrices(project)[source]#

Gateway into the matrices available/recorded in the model

check_exists(name: str) bool[source]#

Checks whether a matrix with a given name exists

Returns:

exists (bool): Does the matrix exist?

clear_database() None[source]#

Removes records from the matrices database that do not exist in disk

delete_record(matrix_name: str) None[source]#

Deletes a Matrix Record from the model and attempts to remove from disk

get_matrix(matrix_name: str) AequilibraeMatrix[source]#

Returns an AequilibraE matrix available in the project

Raises an error if matrix does not exist

Arguments:

matrix_name (str): Name of the matrix to be loaded

Returns:

matrix (AequilibraeMatrix): Matrix object

get_record(matrix_name: str) MatrixRecord[source]#

Returns a model Matrix Record for manipulation in memory

list() DataFrame[source]#

List of all matrices available

Returns:

df (pd.DataFrame): Pandas DataFrame listing all matrices available in the model

new_record(name: str, file_name: str, matrix=None) MatrixRecord[source]#

Creates a new record for a matrix in disk, but does not save it

If the matrix file is not already on disk, it will fail

Arguments:

name (str): Name of the matrix

file_name (str): Name of the file on disk

Returns:

matrix_record (MatrixRecord): A matrix record that can be manipulated in memory before saving

reload()[source]#

Discards all memory matrices in memory and loads recreate them

update_database() None[source]#

Adds records to the matrices database for matrix files found on disk

class aequilibrae.project.data.Results(project, project_conn: Connection | None = None, results_conn: Connection | None = None)[source]#

Gateway into the results available/recorded in the model

check_exists(table_name: str) bool[source]#

Checks whether a result with a given name exists.

Parameters:

**table_name** (str) – Name of the result to check

Returns:

Does the result exist?

Return type:

exists (bool)

clear_database() None[source]#

Removes records from the results table that do not exist in the results database.

delete_record(table_name: str) None[source]#

Deletes a ResultRecord from the model and attempts to remove it from the results database.

Parameters:

**table_name** (str) – Name of the result to delete

Raises:

**ValueError** – If the result doesn’t exist

get_record(table_name: str) ResultRecord[source]#

Returns a model ResultsRecord for manipulation in memory.

Parameters:

**table_name** (str) – Name of the result record to retrieve

Returns:

The requested result record

Return type:

record (ResultRecord)

Raises:

**ValueError** – If the result doesn’t exist or was deleted

get_results(table_name: str) DataFrame[source]#

Returns a DataFrame containing the results.

Raises an error if results do not exist.

Parameters:

**table_name** (str) – Name of the results to be loaded

Returns:

Results as a DataFrame

Return type:

results (pd.DataFrame)

Raises:

**ValueError** – If the result doesn’t exist

list() DataFrame[source]#

List of all results available.

Parameters:

**conn** (Optional[sqlite3.Connection]) – Optional connection to use

Returns:

Pandas DataFrame listing all results available in the model

Return type:

df (pd.DataFrame)

new_record(table_name: str, procedure: str = None, procedure_id: str = None, procedure_report: dict = None, timestamp: str = None, description: str = None, scenario: str = None, year: str = None, reference_table: str = 'links') ResultRecord[source]#

Creates a new record for a result.

Parameters:
  • **table_name** (str) – Name of the table

  • **procedure** (str, optional) – Name of the procedure

  • **procedure_id** (str, optional) – ID of the procedure

  • **procedure_report** (dict, optional) – Report associated with the procedure

  • **timestamp** (str, optional) – Timestamp for the record

  • **description** (str, optional) – Description of the record

Returns:

A result record that can be manipulated in memory before saving

Return type:

result_record (ResultRecord)

Raises:

**ValueError** – If a result with the same name already exists

reload() None[source]#

Reloads the results from the database.

update_database() None[source]#

Adds records to the results table for results found in the results database.

Modules