Skip to content

Commit

Permalink
Check amount to be different than zero in external.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Sep 9, 2024
1 parent 1a1f9bd commit 94b3908
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions premise/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,33 +1480,34 @@ def redefine_loc(e):
if len(new_loc) > 0:
for loc, share in new_loc:
# add new exchange
new_exchanges.append(
{
"amount": exc["amount"] * ratio * share,
"type": "technosphere",
"unit": exc["unit"],
"location": loc,
"name": new_name,
"product": new_ref,
"uncertainty type": exc.get("uncertainty type", 0),
"loc": redefine_loc(exc),
"scale": (
exc.get("scale", 0) if "scale" in exc else None
),
"minimum": (
exc.get("minimum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "minimum" in exc
else None
),
"maximum": (
exc.get("maximum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "maximum" in exc
else None
),
}
)
if exc["amount"] * ratio * share != 0:
new_exchanges.append(
{
"amount": exc["amount"] * ratio * share,
"type": "technosphere",
"unit": exc["unit"],
"location": loc,
"name": new_name,
"product": new_ref,
"uncertainty type": exc.get("uncertainty type", 0),
"loc": redefine_loc(exc),
"scale": (
exc.get("scale", 0) if "scale" in exc else None
),
"minimum": (
exc.get("minimum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "minimum" in exc
else None
),
"maximum": (
exc.get("maximum", 0)
* (exc["amount"] * ratio * share / exc["amount"])
if "maximum" in exc
else None
),
}
)

if isfuel:
fuel_amount += exc["amount"] * ratio * share
Expand Down

0 comments on commit 94b3908

Please sign in to comment.