From 9ff26622585af30ce87a883cdd15aaea287473fa Mon Sep 17 00:00:00 2001 From: belthlemar Date: Wed, 31 Jan 2024 18:37:01 +0100 Subject: [PATCH] resolve other comments --- antarest/study/service.py | 5 +++-- .../raw_studies_blueprint/test_download_matrices.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/antarest/study/service.py b/antarest/study/service.py index 00b2a7e290..5c000ffff1 100644 --- a/antarest/study/service.py +++ b/antarest/study/service.py @@ -322,6 +322,7 @@ def __init__( self.xpansion_manager = XpansionManager(self.storage_service) self.matrix_manager = MatrixManager(self.storage_service) self.binding_constraint_manager = BindingConstraintManager(self.storage_service) + self.correlation_manager = CorrelationManager(self.storage_service) self.cache_service = cache_service self.config = config self.on_deletion_callbacks: t.List[t.Callable[[str], None]] = [] @@ -2446,7 +2447,7 @@ def get_matrix_with_index_and_header( if aggregate == "allocation": hydro_matrix = self.allocation_manager.get_allocation_matrix(study, all_areas) else: - hydro_matrix = CorrelationManager(self.storage_service).get_correlation_matrix(all_areas, study, []) # type: ignore + hydro_matrix = self.correlation_manager.get_correlation_matrix(all_areas, study, []) # type: ignore return pd.DataFrame(data=hydro_matrix.data, columns=hydro_matrix.columns, index=hydro_matrix.index) json_matrix = self.get(study_id, path, depth=3, formatted=True, params=parameters) @@ -2465,7 +2466,7 @@ def get_matrix_with_index_and_header( df_matrix.index = time_column for specific_matrix in SPECIFIC_MATRICES: - if re.compile(specific_matrix).match(path): + if re.match(specific_matrix, path): return _handle_specific_matrices( int(study.version), df_matrix, diff --git a/tests/integration/raw_studies_blueprint/test_download_matrices.py b/tests/integration/raw_studies_blueprint/test_download_matrices.py index f4c57f2ea6..dda885290c 100644 --- a/tests/integration/raw_studies_blueprint/test_download_matrices.py +++ b/tests/integration/raw_studies_blueprint/test_download_matrices.py @@ -209,6 +209,16 @@ def test_download_matrices(self, client: TestClient, admin_access_token: str, st "('HURDLE COST', 'Euro', '')", ] + # test energy matrix to test the regex + res = client.get( + f"/v1/studies/{study_id}/raw/download?path=input/hydro/prepro/de/energy&format=csv", + headers=admin_headers, + ) + assert res.status_code == 200 + content = io.BytesIO(res.content) + dataframe = pd.read_csv(content, index_col=0, sep="\t") + assert dataframe.empty + # ============================= # ERRORS # =============================