From 5c8bc5d5fff758b5fc99e1cf776c1f3f0727f138 Mon Sep 17 00:00:00 2001 From: romainsacchi Date: Mon, 8 Jul 2024 19:00:26 +0000 Subject: [PATCH] Black reformating --- polyviz/choro.py | 4 +--- polyviz/sankey.py | 4 ++-- polyviz/treemap.py | 4 +--- polyviz/utils.py | 9 +++------ polyviz/violin.py | 10 +++------- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/polyviz/choro.py b/polyviz/choro.py index 1a5659d..b353156 100644 --- a/polyviz/choro.py +++ b/polyviz/choro.py @@ -41,9 +41,7 @@ def choro( filepath = check_filepath(filepath, title, "choro", method) assert isinstance(method, tuple), "`method` should be a tuple." - assert isinstance( - activity, Activity - ), "`activity` should be a Brightway activity." + assert isinstance(activity, Activity), "`activity` should be a Brightway activity." # fetch unit of method unit = bw2data.Method(method).metadata["unit"] diff --git a/polyviz/sankey.py b/polyviz/sankey.py index 3a5418c..32682e6 100644 --- a/polyviz/sankey.py +++ b/polyviz/sankey.py @@ -1,9 +1,8 @@ """ This module contains the code to generate a Sankey diagram for a given activity and method. """ -from typing import Optional, Tuple -from typing import Union +from typing import Optional, Tuple, Union import bw2data from d3blocks import D3Blocks @@ -17,6 +16,7 @@ except ImportError: from bw2data.backends import Activity + def sankey( activity: Activity, method: tuple = None, diff --git a/polyviz/treemap.py b/polyviz/treemap.py index 8079d2b..19a0d35 100644 --- a/polyviz/treemap.py +++ b/polyviz/treemap.py @@ -41,9 +41,7 @@ def treemap( filepath = check_filepath(filepath, title, "treemap", method) assert isinstance(method, tuple), "`method` should be a tuple." - assert isinstance( - activity, Activity - ), "`activity` should be a brightway2 activity." + assert isinstance(activity, Activity), "`activity` should be a brightway2 activity." # fetch unit of method unit = bw2data.Method(method).metadata["unit"] diff --git a/polyviz/utils.py b/polyviz/utils.py index 6b0d540..4055473 100644 --- a/polyviz/utils.py +++ b/polyviz/utils.py @@ -19,6 +19,7 @@ except ImportError: from bw2data.backends import Activity + def calculate_supply_chain( activity: Activity, method: tuple, @@ -35,9 +36,7 @@ def calculate_supply_chain( :return: a StringIO object and the reference amount """ - assert isinstance( - activity, Activity - ), "`activity` should be a brightway2 activity." + assert isinstance(activity, Activity), "`activity` should be a brightway2 activity." amount = amount * -1 if identify_waste_process(activity) else amount @@ -70,9 +69,7 @@ def calculate_lcia_score( :param method: tuple representing a Brightway2 method :return: LCIA score, C matrix, and reverse dictionary """ - assert isinstance( - activity, Activity - ), "`activity` should be a brightway2 activity." + assert isinstance(activity, Activity), "`activity` should be a brightway2 activity." print("Calculating LCIA score...") diff --git a/polyviz/violin.py b/polyviz/violin.py index 0584765..e430e7d 100644 --- a/polyviz/violin.py +++ b/polyviz/violin.py @@ -4,10 +4,10 @@ from typing import Union +import bw2calc import bw2data import numpy as np import pandas as pd -import bw2calc try: from bw2calc.monte_carlo import MultiMonteCarlo @@ -46,9 +46,7 @@ def violin( assert isinstance(method, tuple), "`method` should be a tuple." for act in activities: - assert isinstance( - act, Activity - ), "`activity` should be a Brightway activity." + assert isinstance(act, Activity), "`activity` should be a Brightway activity." def make_name(activities): """ @@ -73,9 +71,7 @@ def make_name(activities): ).calculate() else: lca = bw2calc.LCA( - demand={activities[0]: 1}, - method=method, - use_distributions=True + demand={activities[0]: 1}, method=method, use_distributions=True ) lca.lci() lca.lcia()