changeset 749:dd4b9fec8d85

added support for timesData
author mas01mc
date Wed, 24 Nov 2010 13:50:05 +0000
parents e5f96902afaf
children d93292ae7c1b
files bindings/python/pyadb.py bindings/python/pyadbmodule.c
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/bindings/python/pyadb.py	Mon Nov 22 17:58:27 2010 +0000
+++ b/bindings/python/pyadb.py	Wed Nov 24 13:50:05 2010 +0000
@@ -72,11 +72,13 @@
 				args["power"]=powerFile
 			elif featData.any():
 				args["power"]=powerData
+		if timesData != None:
+			self.hasTimes=True
 		if self.hasTimes:
 			if featFile:
 				args["times"]=timesFile
 			elif timesData.any():
-				pass
+				args["times"]=timesData
 		if key:
 			args["key"]=str(key)
 		if featFile:
@@ -94,6 +96,11 @@
 				if (len(args["power"].shape) == 1) : 
 					args["power"] = args["power"].reshape((args["power"].shape[0],1))
 				args["power"] = args["power"].flatten()
+			if(self.hasTimes and timesData != None):
+				if (len(args["times"].shape) == 1) : 
+					args["times"] = args["times"].reshape((args["times"].shape[0],1))
+				args["times"] = args["times"].flatten()
+
 			print "args: " + str(args)
 			ok = _pyadb._pyadb_insertFromArray(**args)
 			if not (ok==0):
--- a/bindings/python/pyadbmodule.c	Mon Nov 22 17:58:27 2010 +0000
+++ b/bindings/python/pyadbmodule.c	Wed Nov 24 13:50:05 2010 +0000
@@ -208,8 +208,8 @@
 			return NULL;
 		}
 		// times = (PyArrayObject *)PyCObject_AsVoidPtr(incomingTime);
-		if (PyArray_NDIM(times) != 1 || PyArray_DIMS(times)[0] == (nVect*2)){
-			PyErr_SetString(PyExc_ValueError, "times, if given must be a 1d numpy array with shape =  (numVectors,)");
+		if (PyArray_NDIM(times) != 1 || PyArray_DIMS(times)[0] != (nVect*2)){
+			PyErr_SetString(PyExc_ValueError, "times, if given must be a 1d numpy array with shape =  (numVectors*2,)");
 			return NULL;
 		}
 	}