[Greater-commits] r3602 - trunk/GREAT-ERModel/GreaterModel/Worker
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jul 15 11:03:33 CEST 2011
Author: aheinecke
Date: 2011-07-15 11:03:32 +0200 (Fri, 15 Jul 2011)
New Revision: 3602
Modified:
trunk/GREAT-ERModel/GreaterModel/Worker/worker.py
Log:
Convert Numpy floats to regular python floats for jelling
Modified: trunk/GREAT-ERModel/GreaterModel/Worker/worker.py
===================================================================
--- trunk/GREAT-ERModel/GreaterModel/Worker/worker.py 2011-07-15 09:02:30 UTC (rev 3601)
+++ trunk/GREAT-ERModel/GreaterModel/Worker/worker.py 2011-07-15 09:03:32 UTC (rev 3602)
@@ -16,6 +16,8 @@
from twisted.python.failure import Failure
import sys
+import numpy
+
import session
from calculation import Calculation
@@ -124,10 +126,19 @@
# get_descriptives method to get a tuple representation
# of the instance variables (which can be combined with
# other results for the same segment later)
+ # Some numpy calculations also return numpy floats which
+ # also can not be jellied and have to be converted
result = calculation.get_results()
for seg in result.values():
for key, value in seg.items():
- seg[key] = value.get_raw()
+ raw = value.get_raw()
+ if isinstance(raw, tuple):
+ raw = list(raw)
+ for i, element in enumerate(raw):
+ if isinstance(element, numpy.float64):
+ raw[i] = float(element)
+ raw = tuple(raw)
+ seg[key] = raw
deferred.callback(result)
else:
# An unknown status of the calculation. Return an error to
More information about the Greater-commits
mailing list