Skip to content

Commit

Permalink
[fix] fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
tngTUDOR committed Mar 18, 2024
1 parent 94c115b commit 2278e27
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ui Changelog

## [0.36.0]

+ add command to show uncertainty fields of exchanges ("un")

## [0.35.0]

+ use brightwaylib cookiecutter recipe to build the package
Expand Down
2 changes: 1 addition & 1 deletion bw2ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# Add functions and variables you want exposed in `bw2ui.` namespace here
)

__version__ = "0.35.0"
__version__ = "0.36.0"
23 changes: 22 additions & 1 deletion bw2ui/bin/bw2_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
up: List upstream activities with pedigree info if avail (inputs for the current \
activity).
uu: List upstream activities with formula info if avail.
un: display uncertainty information of upstream activitities if avail.
d: List downstream activities (activities which consume current activity).
b: List biosphere flows for the current activity.
cfs: Show characterization factors for current activity and current method.
Expand Down Expand Up @@ -522,7 +523,13 @@ def choose_activity(self, key, restored=False):
self.update_prompt()

def format_exchanges_as_options(
self, es, kind, unit_override=None, show_formulas=False, show_pedigree=False
self,
es,
kind,
unit_override=None,
show_formulas=False,
show_pedigree=False,
show_uncertainty=False,
):
objs = []
for exc in es:
Expand All @@ -537,6 +544,9 @@ def format_exchanges_as_options(
"amount": exc["amount"],
"formula": exc.get("formula", None),
"pedigree": exc.get("pedigree", None),
"loc": exc.get("loc", None),
"scale": exc.get("scale", None),
"uncertainty_type": exc.get("uncertainty_type", None),
"key": exc["input"],
}
)
Expand All @@ -545,6 +555,8 @@ def format_exchanges_as_options(
format_string = "%(amount).3g [=%(formula)s] %(unit)s %(name)s (%(location)s)" # NOQA: E501
elif show_pedigree:
format_string = "%(amount).3g %(unit)s %(name)s (%(location)s)\n\t[pedigree: %(pedigree)s] " # NOQA: E501
elif show_uncertainty:
format_string = "%(amount).3g %(unit)s %(name)s (%(location)s)\n\t[uncertainty type: %(uncertainty_type)s, scale: %(scale)s, loc: %(loc)s] " # NOQA: E501
else:
format_string = "%(amount).3g %(unit)s %(name)s (%(location)s)"

Expand Down Expand Up @@ -1194,6 +1206,15 @@ def do_uu(self, arg):
self.format_exchanges_as_options(es, "technosphere", show_formulas=True)
self.print_current_options("Upstream inputs")

def do_un(self, arg):
"""Display uncertainty infor of upstream activities if available"""
if not self.activity:
print("Need to choose an activity first")
else:
es = get_activity(self.activity).technosphere()
self.format_exchanges_as_options(es, "technosphere", show_uncertainty=True)
self.print_current_options("Upstream inputs")

def do_web(self, arg):
"""Open a web browser to current activity"""
if not self.activity:
Expand Down

0 comments on commit 2278e27

Please sign in to comment.