diff --git a/pathways/data_validation.py b/pathways/data_validation.py index 5e791b7..98517b7 100644 --- a/pathways/data_validation.py +++ b/pathways/data_validation.py @@ -19,7 +19,9 @@ ) -def validate_datapackage(datapackage: datapackage.DataPackage) -> (datapackage.DataPackage, pd.DataFrame, list): +def validate_datapackage( + datapackage: datapackage.DataPackage, +) -> (datapackage.DataPackage, pd.DataFrame, list): """ Validate the datapackage.json file. The datapackage must be valid according to the Frictionless Data. diff --git a/pathways/lca.py b/pathways/lca.py index 69d4866..bc3abd4 100644 --- a/pathways/lca.py +++ b/pathways/lca.py @@ -121,8 +121,11 @@ def get_lca_matrices( # the model, scenario and year def filter_filepaths(suffix: str, contains: List[str]): return [ - Path(fp) for fp in filepaths - if all(kw in fp for kw in contains) and Path(fp).suffix == suffix and Path(fp).exists() + Path(fp) + for fp in filepaths + if all(kw in fp for kw in contains) + and Path(fp).suffix == suffix + and Path(fp).exists() ] def select_filepath(keyword: str, fps): diff --git a/pathways/pathways.py b/pathways/pathways.py index e64ecf4..650d707 100644 --- a/pathways/pathways.py +++ b/pathways/pathways.py @@ -296,15 +296,12 @@ def process_region(data: Tuple) -> dict[str, ndarray[Any, dtype[Any]] | list[int year=year, ) - share = ( - demand - / scenarios.sel( - region=region, - model=model, - pathway=scenario, - year=year, - ).sum(dim="variables") - ) + share = demand / scenarios.sel( + region=region, + model=model, + pathway=scenario, + year=year, + ).sum(dim="variables") # If the total demand is zero, return None if share < demand_cutoff: @@ -547,7 +544,9 @@ class Pathways: def __init__(self, datapackage, debug=False): self.datapackage = datapackage - self.data, dataframe, self.filepaths = validate_datapackage(self.read_datapackage()) + self.data, dataframe, self.filepaths = validate_datapackage( + self.read_datapackage() + ) self.mapping = self.get_mapping() self.mapping.update(self.get_final_energy_mapping()) self.debug = debug