Anonymous avatar Anonymous committed 06c23f3 Merge

merge

Comments (0)

Files changed (2)

accesscarray/accesscarraymodule.c

 check_pointer(PyObject *dummy, PyObject *args)
 {
   int nd;
-  PyObject *obj;
+  PyObject *obj, *rtn;
   char *data;
   void *elem;
   int index;
     return NULL;
   }
 
+  rtn = PyArray_SimpleNew(PyArray_NDIM(obj), PyArray_DIMS(obj), NPY_INT);
+  if (rtn == NULL){
+    return NULL;
+  }
+
   nd = PyArray_NDIM(obj);
   data = PyArray_BYTES(obj);
 
 	
 	if (PyArray_GETPTR1(obj, i) == elem){
 	  PySys_WriteStdout(".");
+	  *(int *)PyArray_GETPTR1(rtn,i) = 0;
 	}else{
 	  num_missmatch++;
 	  PySys_WriteStdout("!");
+	  *(int *)PyArray_GETPTR1(rtn,i) = 1;
 	}
 	num_elem++;
       }
 
       for (i = 0; i < n0; ++i){
 	for (j = 0; j < n1; ++j){
-	  index = i*n0 + j;
+	  index = i*n1 + j;
 
 	  if (PyArray_ISFLOAT(obj)){
 	    elem = (void *)&((double *)data)[index];
 
 	  if (PyArray_GETPTR2(obj,i,j) == elem){
 	    PySys_WriteStdout(".");
+	    *(int *)PyArray_GETPTR2(rtn,i,j) = 0;
 	  }else{
 	    num_missmatch++;
 	    PySys_WriteStdout("!");
+	    *(int *)PyArray_GETPTR2(rtn,i,j) = 1;
 	  }
 	  num_elem++;
 	}
       for (i = 0; i < n0; ++i){
 	for (j = 0; j < n1; ++j){
 	  for (k = 0; k < n2; ++k){
-	    index = i*n0*n1 + j*n1 + k;
+	    index = i*n1*n2 + j*n2 + k;
 
 	    if (PyArray_ISFLOAT(obj)){
 	      elem = (void *)&((double *)data)[index];
 
 	    if (PyArray_GETPTR3(obj,i,j,k) == elem){
 	      PySys_WriteStdout(".");
+	      *(int *)PyArray_GETPTR3(rtn,i,j,k) = 0;
 	    }else{
 	      num_missmatch++;
 	      PySys_WriteStdout("!");
+	      *(int *)PyArray_GETPTR3(rtn,i,j,k) = 1;
 	    }
 	    num_elem++;
 	  }
 	for (j = 0; j < n1; ++j){
 	  for (k = 0; k < n2; ++k){
 	    for (l = 0; l < n3; ++l){
-	      
-	      index = i*n0*n1*n2 + j*n1*n2 + k*n2 + l;
+	      index = i*n1*n2*n3 + j*n2*n3 + k*n3 + l;
 
 	      if (PyArray_ISFLOAT(obj)){
 		elem = (void *)&((double *)data)[index];
 
 	      if (PyArray_GETPTR4(obj,i,j,k,l) == elem){
 		PySys_WriteStdout(".");
+		*(int *)PyArray_GETPTR4(rtn,i,j,k,l) = 0;
 	      }else{
 		num_missmatch++;
 		PySys_WriteStdout("!");
+		*(int *)PyArray_GETPTR4(rtn,i,j,k,l) = 1;
 	      }
 	      num_elem++;
 	    }
   PySys_WriteStdout("Missmatch: %.2f%% (%d/%d) \n",
 		    100.0*num_missmatch/num_elem, num_missmatch, num_elem);
 
-  return Py_BuildValue("");  /* return None */
+  return rtn;
 }
 
 

accesscarray/check_pointer.py

 fac4d = fa_4d.copy('C')
 faf4d = fa_4d.copy('F')
 
-check_pointer(iac1d)
-check_pointer(iaf1d)
-check_pointer(fac1d)
-check_pointer(faf1d)
-check_pointer(fac2d)
-check_pointer(faf2d)
-check_pointer(fac3d)
-check_pointer(faf3d)
-check_pointer(fac4d)
-check_pointer(faf4d)
+print check_pointer(iac1d)
+print check_pointer(iaf1d)
+print check_pointer(fac1d)
+print check_pointer(faf1d)
+print check_pointer(fac2d)
+print check_pointer(faf2d)
+print check_pointer(fac3d)
+print check_pointer(faf3d)
+print check_pointer(fac4d)
+print check_pointer(faf4d)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.