[cig-commits] r5970 - cs/spatialdata-0.1/trunk/tests/pytests/utils
leif at geodynamics.org
leif at geodynamics.org
Tue Feb 6 16:06:10 PST 2007
Author: leif
Date: 2007-02-06 16:06:10 -0800 (Tue, 06 Feb 2007)
New Revision: 5970
Added:
cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src
Removed:
cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe
Modified:
cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am
Log:
Fixed another instance of the .pyxe problem.
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am 2007-02-06 03:53:28 UTC (rev 5969)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am 2007-02-07 00:06:10 UTC (rev 5970)
@@ -33,14 +33,16 @@
INCLUDES += -I$(PYTHON_INCDIR)
testcpp.pyx testcpp_embed.cpp testcpp_embed.h: testcpp.pyxe
- cp $< . && pyrexembed testcpp.pyxe && rm -f testcpp.pyxe
+ pyrexembed testcpp.pyxe
+testcpp.pyxe: $(srcdir)/testcpp.pyxe.src
+ cp $(srcdir)/testcpp.pyxe.src $@
testcpp_embed.cpp: testcpp_embed.h
testcpp_embed.h: testcpp.pyx
.pyx.c:
pyrexc $<
-CLEANFILES = testcpp.pyx testcpp.c *_embed.*
+CLEANFILES = testcpp.pyxe testcpp.pyx testcpp.c *_embed.*
# version
Deleted: cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe 2007-02-06 03:53:28 UTC (rev 5969)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe 2007-02-07 00:06:10 UTC (rev 5970)
@@ -1,77 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-cdef extern from "math.h":
- double fabs(double)
-
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*func)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-def cpparray():
- # create shim to create array
- #embed{ void cpparray_create(double** ppData, int* pSize)
- const double pVals[] = { 1.1, 2.1, 3.1, 1.2, 2.2, 3.2 };
- const int size = 6;
- delete[] *ppData; *ppData = new double[size];
- for (int i=0; i < size; ++i)
- (*ppData)[i] = pVals[i];
- #}embed
-
- import spatialdata.utils.simplearray
-
- cdef double* pData
- cdef int size
- pData = NULL
- cpparray_create(&pData, &size)
- dims = [2, 3]
- pDataObj = PyCObject_FromVoidPtr(pData, NULL);
- return spatialdata.utils.simplearray.SimpleCppArray(pDataObj, dims, "double")
-
-
-def test(sarray):
-
- valsE = [1.1, 2.1, 1.2, 2.2, 1.3, 2.3]
- shapeE = [3, 2]
-
- if not sarray.name == "spatialdata_utils_SimpleArray":
- raise TypeError("Argument 'values' must be of type "
- "'spatialdata_utils_SimpleArray'.")
-
- if not sarray.isCompatible(nd=2,
- simpletype="double",
- writeable=True,
- contiguous=True,
- notswapped=True):
- raise TypeError("Argument must be a contiguous, writeable, "
- "2-D array of type double.")
-
- cdef double* pVals
- pVals = <double*> PyCObject_AsVoidPtr(sarray.data)
-
- if len(shapeE) != len(sarray.shape):
- raise ValueError("Mismatch in shape.")
- for dE,d in zip(shapeE, sarray.shape):
- if dE != d:
- raise ValueError("Mismatch in dimensions.")
- size = len(valsE)
- tolerance = 1.0e-6
- for i from 0 <= i < size:
- if fabs(1.0 - valsE[i]/pVals[i]) > tolerance:
- raise ValueError("Mismatch in values.")
- return
-
-
-# version
-__id__ = "$Id$"
-
-# End of file
Copied: cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src (from rev 5969, cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe)
More information about the cig-commits
mailing list