Commits

Chris Mutel committed 8e150e0

9.3.2: Fix small import bugs due to new stats_array naming scheme

  • Participants
  • Parent commits 9fcb577

Comments (0)

Files changed (3)

File bw2data/__init__.py

 import validate
 import io
 
-__version__ = (0, 9, 3, 1)
+__version__ = (0, 9, 3, 2)

File bw2data/io/import_ecospold.py

 
     def process_uncertainty_fields(self, exc, data):
         uncertainty = int(exc.get("uncertaintyType", 0))
-        mean = exc.get("meanValue")
-        min_ = exc.get("minValue")
-        max_ = exc.get("maxValue")
-        sigma = exc.get("standardDeviation95")
+
+        def floatish(x):
+            try:
+                return float(x)
+            except:
+                return np.NaN
+
+        mean = floatish(exc.get("meanValue"))
+        min_ = floatish(exc.get("minValue"))
+        max_ = floatish(exc.get("maxValue"))
+        sigma = floatish(exc.get("standardDeviation95"))
 
         if uncertainty == 1:
             # Lognormal
                 'scale': math.log(math.sqrt(float(sigma))),
                 'negative': mean < 0,
             })
-            if data['sigma'] == 0:
+            if data['scale'] == 0 or np.isnan(data['scale']):
                 # Bad ecoinvent data
                 data['uncertainty type'] = UndefinedUncertainty.id
                 data['loc'] = data['amount']
-                del data["sigma"]
+                del data["scale"]
         elif uncertainty == 2:
             # Normal
             data.update({
             })
             # Sometimes this isn't included (though it SHOULD BE)
             if exc.get("mostLikelyValue"):
-                mode = float(exc.get("mostLikelyValue"))
+                mode = floatish(exc.get("mostLikelyValue"))
                 data['amount'] = data['loc'] = mode
             else:
                 data['amount'] = data['loc'] = float(mean)
 
 setup(
     name='bw2data',
-    version="0.9.3.1",
+    version="0.9.3.2",
     packages=packages,
     author="Chris Mutel",
     author_email="cmutel@gmail.com",