Skip to content

Commit

Permalink
Black reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Apr 9, 2024
1 parent 9e4f6df commit 5437779
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion pathways/data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions pathways/lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 9 additions & 10 deletions pathways/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5437779

Please sign in to comment.