From dfed7f779ba2bebc5053796c7044381d93fb9be0 Mon Sep 17 00:00:00 2001 From: Florian Ulrich Jehn Date: Tue, 30 Jan 2024 13:51:33 +0100 Subject: [PATCH 1/2] Fixed flake8 errors --- .flake8 | 1 + src/model.py | 4 ++-- tests/test_model.py | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 7da1f96..41a0a51 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,3 @@ [flake8] max-line-length = 100 +ignore = F821 diff --git a/src/model.py b/src/model.py index aeeae1b..86d697f 100644 --- a/src/model.py +++ b/src/model.py @@ -216,10 +216,10 @@ def remove_net_zero_countries(self) -> None: # print the number of countries removed print( - f"Removed {shape_before - self.trade_matrix.shape[0]} countries with no trade or production." + f"Removed {shape_before - self.trade_matrix.shape[0]} " + f"countries with no trade or production." ) - def prebalance(self, precision=10**-3) -> None: """ This implementation also includes pre-balancing to ensure that countries don't diff --git a/tests/test_model.py b/tests/test_model.py index cbfdabd..54b603a 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -3,7 +3,6 @@ import os import numpy as np from src.preprocessing import rename_countries -import country_converter as coco def loading(region): From 048afb715b786d458af0e467e018762dfefd3454 Mon Sep 17 00:00:00 2001 From: Florian Ulrich Jehn Date: Tue, 30 Jan 2024 13:57:16 +0100 Subject: [PATCH 2/2] Fixed black errors --- src/preprocessing.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/preprocessing.py b/src/preprocessing.py index ee97b4b..5b35f26 100644 --- a/src/preprocessing.py +++ b/src/preprocessing.py @@ -74,11 +74,11 @@ def serialise_faostat_bulk(faostat_zip: str) -> None: """ data = read_faostat_bulk(faostat_zip) print("Starting to convert zip to pickle") - data.to_pickle( - f"data{os.sep}temp_files{os.sep}{faostat_zip[faostat_zip.rfind('/') + 1:].replace( - 'zip', 'pkl' - )}" - ) + base_path = "data" + os.sep + "temp_files" + os.sep + formatted_filename = faostat_zip[faostat_zip.rfind('/') + 1:].replace('zip', 'pkl') + full_path = f"{base_path}{formatted_filename}" + + data.to_pickle(full_path) print("Finished converting zip to pickle") return None