File tree Expand file tree Collapse file tree
activity_browser/ui/tables/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from logging import getLogger
55
66import pandas as pd
7+ import numpy as np
78from asteval import Interpreter
89from bw2data .parameters import (ActivityParameter , DatabaseParameter , Group ,
910 ProjectParameter )
@@ -62,9 +63,13 @@ def create_row(self, exchange) -> dict:
6263 """Take the given Exchange object and extract a number of attributes."""
6364 try :
6465 # fixing a broken exchange
65- if not isinstance (exchange .get ("amount" ), float ):
66+ if not isinstance (exchange .get ("amount" ), float ) or pd . isna ( exchange . get ( "amount" )) :
6667 log .warning (f"Fixing broken exchange amount for { exchange .get ('type' , '' )} exchange from: { exchange .input } " )
67- exchange ["amount" ] = 1.0 # Ensure amount is a float
68+ try :
69+ amount = float (exchange .get ("amount" )) if exchange .get ("amount" ) is not np .nan else 1.0
70+ except TypeError :
71+ amount = 1.0
72+ exchange ["amount" ] = amount
6873 exchange .save ()
6974
7075 row = {
You can’t perform that action at this time.
0 commit comments