From e5772c79b242a2ff4f839313d0c2cec75191fac0 Mon Sep 17 00:00:00 2001 From: Emily Przykucki Date: Wed, 20 Nov 2024 12:56:03 -0500 Subject: [PATCH] linting with `black` --- flepimop/gempyor_pkg/src/gempyor/seir.py | 6 ++---- flepimop/gempyor_pkg/src/gempyor/statistics.py | 6 +++--- flepimop/gempyor_pkg/tests/seir/test_seir.py | 4 +++- .../gempyor_pkg/tests/statistics/test_statistic_class.py | 8 ++------ flepimop/gempyor_pkg/tests/utils/test_utils.py | 4 +++- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/flepimop/gempyor_pkg/src/gempyor/seir.py b/flepimop/gempyor_pkg/src/gempyor/seir.py index 7bbf6995c..b5742efad 100644 --- a/flepimop/gempyor_pkg/src/gempyor/seir.py +++ b/flepimop/gempyor_pkg/src/gempyor/seir.py @@ -165,7 +165,7 @@ def steps_SEIR( ]: if modinf.stoch_traj_flag == True: raise ValueError( - f"'{integration_method}' integration method only supports deterministic integration, but `stoch_straj_flag` is '{modinf.stoch_traj_flag}'." + f"'{integration_method}' integration method only supports deterministic integration, but `stoch_straj_flag` is '{modinf.stoch_traj_flag}'." ) seir_sim = steps_experimental.ode_integration( **fnct_args, integration_method=integration_method @@ -187,9 +187,7 @@ def steps_SEIR( elif integration_method == "rk4_aot": seir_sim = steps_experimental.rk4_aot(**fnct_args) else: - raise ValueError( - f"Unknown integration method given, '{integration_method}'." - ) + raise ValueError(f"Unknown integration method given, '{integration_method}'.") # We return an xarray instead of a ndarray now compartment_coords = {} diff --git a/flepimop/gempyor_pkg/src/gempyor/statistics.py b/flepimop/gempyor_pkg/src/gempyor/statistics.py index 3208a6569..b6ced5e6d 100644 --- a/flepimop/gempyor_pkg/src/gempyor/statistics.py +++ b/flepimop/gempyor_pkg/src/gempyor/statistics.py @@ -301,9 +301,9 @@ def compute_logloss( if not model_data.shape == gt_data.shape: raise ValueError( - f"`model_data` and `gt_data` do not have " - f"the same shape: `model_data.shape` = '{model_data.shape}' != " - f"`gt_data.shape` = '{gt_data.shape}'." + f"`model_data` and `gt_data` do not have " + f"the same shape: `model_data.shape` = '{model_data.shape}' != " + f"`gt_data.shape` = '{gt_data.shape}'." ) regularization = 0.0 diff --git a/flepimop/gempyor_pkg/tests/seir/test_seir.py b/flepimop/gempyor_pkg/tests/seir/test_seir.py index b14767115..9cf89032e 100644 --- a/flepimop/gempyor_pkg/tests/seir/test_seir.py +++ b/flepimop/gempyor_pkg/tests/seir/test_seir.py @@ -128,7 +128,9 @@ def test_constant_population_legacy_integration(): def test_constant_population_rk4jit_integration_fail(): - with pytest.raises(ValueError, match=r".*integration method only supports deterministic integration.*"): + with pytest.raises( + ValueError, match=r".*integration method only supports deterministic integration.*" + ): config.set_file(f"{DATA_DIR}/config.yml") first_sim_index = 1 diff --git a/flepimop/gempyor_pkg/tests/statistics/test_statistic_class.py b/flepimop/gempyor_pkg/tests/statistics/test_statistic_class.py index d9d4270e4..5ec48ba76 100644 --- a/flepimop/gempyor_pkg/tests/statistics/test_statistic_class.py +++ b/flepimop/gempyor_pkg/tests/statistics/test_statistic_class.py @@ -248,9 +248,7 @@ def test_unsupported_regularizations_value_error( ] if reg_name not in ["forecast", "allsubpop"] ) - with pytest.raises( - ValueError, match=r"^Unsupported regularization \[received:.*$" - ): + with pytest.raises(ValueError, match=r"^Unsupported regularization \[received:.*$"): mock_inputs.create_statistic_instance() @pytest.mark.parametrize("factory", all_valid_factories) @@ -522,9 +520,7 @@ def test_compute_logloss_data_misshape_value_error( model_rows, model_cols = mock_inputs.model_data[mock_inputs.config["sim_var"]].shape gt_rows, gt_cols = mock_inputs.gt_data[mock_inputs.config["data_var"]].shape - expected_match = ( - rf".*do not have the same shape:.*" - ) + expected_match = rf".*do not have the same shape:.*" with pytest.raises(ValueError, match=expected_match): statistic.compute_logloss(mock_inputs.model_data, mock_inputs.gt_data) diff --git a/flepimop/gempyor_pkg/tests/utils/test_utils.py b/flepimop/gempyor_pkg/tests/utils/test_utils.py index 942d79588..c57ac900e 100644 --- a/flepimop/gempyor_pkg/tests/utils/test_utils.py +++ b/flepimop/gempyor_pkg/tests/utils/test_utils.py @@ -37,7 +37,9 @@ def test_read_df_and_write_success(fname, extension): ("fname", "extension"), [("mobility", "csv"), ("usa-geoid-params-output", "parquet")] ) def test_read_df_and_write_fail(fname, extension): - with pytest.raises(NotImplementedError, match=r".*Supported extensions are `.csv` or `.parquet`."): + with pytest.raises( + NotImplementedError, match=r".*Supported extensions are `.csv` or `.parquet`." + ): os.chdir(tmp_path) os.makedirs("data", exist_ok=True) os.chdir("data")