[cig-commits] r13886 - in cs/spatialdata-0.1/trunk: . doc modulesrc/utils tests/pytests/spatialdb tests/pytests/utils
brad at geodynamics.org
brad at geodynamics.org
Sun Jan 18 20:55:41 PST 2009
Author: brad
Date: 2009-01-18 20:55:40 -0800 (Sun, 18 Jan 2009)
New Revision: 13886
Removed:
cs/spatialdata-0.1/trunk/Make.mm
cs/spatialdata-0.1/trunk/doc/Make.mm
cs/spatialdata-0.1/trunk/modulesrc/utils/simplearray.pyxe.src
cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe.src
cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src
Modified:
cs/spatialdata-0.1/trunk/doc/Makefile.am
cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/Makefile.am
cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am
Log:
Cleaned up of Makefiles.
Deleted: cs/spatialdata-0.1/trunk/Make.mm
===================================================================
--- cs/spatialdata-0.1/trunk/Make.mm 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/Make.mm 2009-01-19 04:55:40 UTC (rev 13886)
@@ -1,38 +0,0 @@
-# -*- Makefile -*-
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-PROJECT = spatialdata
-PACKAGE =
-
-RECURSE_DIRS = \
- pkgs \
-
-OTHERS = \
-
-# ----------------------------------------------------------------------
-
-all:
- BLD_ACTION="all" $(MM) recurse
-
-clean::
- BLD_ACTION="clean" $(MM) recurse
-
-tidy::
- BLD_ACTION="tidy" $(MM) recurse
-
-builddoc:
- $(MM) -C doc
-
-# version
-# $Id: Make.mm,v 1.3 2005/05/25 19:10:33 baagaard Exp $
-
-# End of file
Deleted: cs/spatialdata-0.1/trunk/doc/Make.mm
===================================================================
--- cs/spatialdata-0.1/trunk/doc/Make.mm 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/doc/Make.mm 2009-01-19 04:55:40 UTC (rev 13886)
@@ -1,26 +0,0 @@
-# -*- Makefile -*-
-#
-# ----------------------------------------------------------------------
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# <LicenseText>
-#
-# ----------------------------------------------------------------------
-#
-
-PROJECT = spatialdata
-PACKAGE = doc
-
-all builddoc:
- doxygen doxyconfig
-
-clean::
- $(RM) $(RMFLAGS) html
-
-# version
-# $Id: Make.mm,v 1.1 2005/03/17 22:18:34 baagaard Exp $
-
-#
-# End of file
Modified: cs/spatialdata-0.1/trunk/doc/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/doc/Makefile.am 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/doc/Makefile.am 2009-01-19 04:55:40 UTC (rev 13886)
@@ -13,7 +13,7 @@
noinst_HEADERS = \
doxyconfig
-# version
-# $Id$
+doc:
+ doxygen doxyconfig
# End of file
Deleted: cs/spatialdata-0.1/trunk/modulesrc/utils/simplearray.pyxe.src
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/utils/simplearray.pyxe.src 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/modulesrc/utils/simplearray.pyxe.src 2009-01-19 04:55:40 UTC (rev 13886)
@@ -1,415 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- ctypedef int Py_intptr_t
- void Py_INCREF(object)
- void Py_DECREF(object)
- long PyInt_AsLong(object)
- object PyCObject_FromVoidPtr(void*, void (*func)(void*))
- object PyCObject_FromVoidPtrAndDesc(void* cobj, void* desc,
- void (*func)(void*, void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef extern from "stdlib.h":
- ctypedef int size_t
- ctypedef long intptr_t
- void* malloc(size_t size)
- void free(void* ptr)
-
-ctypedef struct PyArrayInterface:
- int version
- int nd
- char typekind
- int itemsize
- int flags
- Py_intptr_t* shape
- Py_intptr_t* strides
- void* data
-
-CONTIGUOUS = 0x01
-FORTRAN = 0x02
-ALIGNED = 0x100
-NOTSWAPPED = 0x200
-WRITEABLE = 0x400
-
-# Byte order used in PyArrayInterface
-byteorder = {'<': "little",
- '>': "big"}
-import sys
-
-# ----------------------------------------------------------------------
-cdef void interface_destructor(void* ptr, void* array):
- Py_DECREF(<object> array)
-
-# ----------------------------------------------------------------------
-cdef int _sanitylevel
-_sanitylevel = 2
-def sanitylevel(int level):
- global _sanitylevel
- _sanitylevel = level
- return
-
-
-cdef int _debuglevel
-_debuglevel = 1
-def debuglevel(int level):
- global _debuglevel
- _debuglevel = level
- return
-
-
-# ----------------------------------------------------------------------
-cdef class SimpleArray:
- """Abstract base class for generic multi-dimensional array holding
- simple C/C++ datatypes that is compatible with NumPy, Numeric, and
- numarray."""
-
- cdef readonly object name # Identifier for type of object
- cdef readonly int nd # Number of dimensions in array
- cdef readonly object shape # Dimensions of array
- cdef readonly object strides # Strides for array
- cdef readonly object data # PyCObject holding pointer to data
-
- cdef object _typeinfo # Dictionary containing information about type in array
- cdef PyArrayInterface* _interface # Array interface
- cdef Py_intptr_t* _cshape # C array for shape information
- cdef Py_intptr_t* _cstrides # C array for strides information
-
- def __init__(self):
- """Constructor."""
- self.name = "spatialdata_utils_SimpleArray"
- self.nd = 0
- self.shape = None
- self.strides = None
- self._typeinfo = None
- self._interface = NULL
- self._cshape = NULL
- self._cstrides = NULL
- return
-
-
- def __dealloc__(self):
- """Destructor."""
- free(self._interface)
- free(self._cshape)
- free(self._cstrides)
- return
-
-
- def isCompatible(self, nd=None, simpletype=None,
- writeable=None, contiguous=None, notswapped=None):
- """Check compatibility with requested traits. Return True if
- compatible, False if not."""
- global _sanitylevel
- global _debuglevel
-
- # Skip checks if sanity level < 1
- if _sanitylevel < 1:
- return True
-
- if not nd is None:
- if not nd == self.nd:
- if _debuglevel > 0:
- print "Expected nd '%d' but have nd '%d'." % \
- (nd, self.nd)
- return False
- if not simpletype is None:
- if not simpletype == self._typeinfo['type']:
- if _debuglevel > 0:
- print "Expected type '%s' but have type '%s'." % \
- (simpletype, self._typeinfo['type'])
- return False
- flags = 0
- if not writeable is None:
- flags = flags | WRITEABLE
- if not contiguous is None:
- flags = flags | CONTIGUOUS
- if not notswapped is None:
- flags = flags | NOTSWAPPED
- if not self._interface.flags & flags:
- if _debuglevel > 0:
- print "Incorrect attribute flags."
- return False
-
- if _sanitylevel > 1:
- # make sure strides are compatible
- ndims = len(self.strides)
- stride = self._typeinfo['size']
- for i from 0 <= i < ndims:
- j = ndims-i-1
- if not self.strides[j] == stride:
- if _debuglevel > 0:
- print "Expected stride '%d' but have stride '%d'." % \
- (stride, self.strides[j])
- return False
- stride = stride * self.shape[j]
-
- return True
-
-
- cdef _setupInterface(self, void* data, int flags):
- """Create array interface."""
- self._syncCShape()
- self._syncCStrides()
-
- cdef PyArrayInterface* interface
- interface = <PyArrayInterface*> malloc(sizeof(PyArrayInterface))
- if interface is NULL:
- raise MemoryError("Could not allocate array interface.")
- interface.version = 2
- interface.nd = self.nd
- interface.typekind = ord(self._typeinfo['kind'])
- interface.itemsize = self._typeinfo['size']
- interface.flags = flags
- interface.strides = self._cstrides
- interface.shape = self._cshape
- interface.data = data
- self._interface = interface
- self.data = PyCObject_FromVoidPtr(data, NULL)
- return
-
-
- cdef _calcStrides(self):
- """Calculate strides for contiguous storage in row major (C/C++) order."""
- nd = self.nd
- self.strides = [0]*nd
- stride = self._typeinfo['size']
- for i from 0 <= i < nd:
- j = nd-i-1
- self.strides[j] = stride
- stride = stride * self.shape[j]
- return
-
-
- cdef _syncCShape(self):
- """Synchronize C shape array with Python shape array."""
- free(self._cshape)
- self._cshape = NULL
- nd = len(self.shape)
- if nd > 0:
- self._cshape = <Py_intptr_t*> malloc(nd*sizeof(Py_intptr_t))
- if self._cshape is NULL:
- raise MemoryError("Could not allocate shape array.")
- for i from 0 <= i < nd:
- self._cshape[i] = self.shape[i]
- return
-
-
- cdef _syncCStrides(self):
- """Synchronize C strides array with Python strides array."""
- free(self._cstrides)
- self._cstrides = NULL
- nd = len(self.strides)
- if nd > 0:
- self._cstrides = <Py_intptr_t*> malloc(nd*sizeof(Py_intptr_t))
- if self._cstrides is NULL:
- raise MemoryError("Could not allocate strides array.")
- for i from 0 <= i < nd:
- self._cstrides[i] = self.strides[i]
- return
-
-
-# ----------------------------------------------------------------------
-cdef class SimpleCppArray(SimpleArray):
- """
- Implementation of generic multi-dimensional array created from C++
- array.
- """
-
- cdef void* arrayptr # Pointer to head of array
-
- def __init__(self, data, shape, valuetype):
- """Constructor."""
- SimpleArray.__init__(self)
-
- nd = len(shape)
- self.arrayptr = PyCObject_AsVoidPtr(data)
- self.nd = nd
- self._typeinfo = self._sizeandtype(valuetype)
-
- self.shape = [0]*nd
- for i in range(nd):
- self.shape[i] = shape[i]
-
- self._calcStrides()
-
- flags = NOTSWAPPED | ALIGNED | CONTIGUOUS | WRITEABLE
- self._setupInterface(self.arrayptr, flags)
- return
-
-
- def __dealloc__(self):
- """Destructor."""
- # create shim for 'delete'
- #embed{ void PyCppArray_deletedouble(void* pData)
- double* pArray = (double*) pData;
- delete[] pArray;
- #}embed
- #embed{ void PyCppArray_deletefloat(void* pData)
- float* pArray = (float*) pData;
- delete[] pArray;
- #}embed
- #embed{ void PyCppArray_deleteint(void* pData)
- int* pArray = (int*) pData;
- delete[] pArray;
- #}embed
- if self._typeinfo['type'] == "double":
- PyCppArray_deletedouble(self.arrayptr)
- elif self._typeinfo['type'] == "float":
- PyCppArray_deletefloat(self.arrayptr)
- elif self._typeinfo['type'] == "int":
- PyCppArray_deleteint(self.arrayptr)
- return
-
-
- property __array_struct__:
- """
- Generic array structure property compatible with NumPy, Numeric,
- and numarray.
- """
- def __get__(self):
- Py_INCREF(self)
- obj = PyCObject_FromVoidPtrAndDesc(<void*> self._interface, <void*> self,
- interface_destructor)
- return obj
-
-
- cdef _sizeandtype(self, valuetype):
- """
- Get size and type information associated with C++ datatype.
- """
- info = {'double': {'size': sizeof(double),
- 'kind': 'f',
- 'type': "double"},
- 'float': {'size': sizeof(float),
- 'kind': 'f',
- 'type': "float"},
- 'int': {'size': sizeof(int),
- 'kind': 'i',
- 'type': "int"}}
- if not valuetype in info.keys():
- raise ValueError("Unknown C type in setting up SimpleArray.")
- return info[valuetype]
-
-
-# ----------------------------------------------------------------------
-cdef class SimplePyArray(SimpleArray):
- """Implementation of generic multi-dimensional array created from Python
- object with __array_struct__ property."""
-
- cdef object _pyarray # Python object holding array data
-
- def __init__(self, pyarray):
- """Constuctor."""
- SimpleArray.__init__(self)
-
- # Array interface version 2 (numpy < 1.0?)
- #shape = pyarray.__array_shape__ # Array interface version 2
- #typestring = pyarray.__array_typestr__
- #strides = pyarray.__array_strides__
- #address = int(pyarray.__array_data__[0], 16)
- #readonly = pyarray.__array_data__[1]
-
- # Array interface version ? (numpy >= 1.0)
- pyarrayInfo = pyarray.__array_interface__
- shape = pyarrayInfo['shape']
- typestring = pyarrayInfo['typestr']
- strides = pyarrayInfo['strides']
- address = int(pyarrayInfo['data'][0])
- readonly = pyarrayInfo['data'][1]
-
- nd = len(shape)
- self.nd = nd
-
- self.shape = [0]*nd
- for i in range(nd):
- self.shape[i] = shape[i]
-
- self._typeinfo = self._sizeandtype(typestring[1:])
-
- if strides:
- self.strides = [0]*nd
- for i from 0 <= i < nd:
- self.strides[i] = strides[i]
- else:
- self._calcStrides()
-
- cdef void* data
- data = <void*> PyInt_AsLong(address)
-
- flags = 0
- if '|' == typestring[0]:
- flags = flags | NOTSWAPPED
- elif byteorder[typestring[0]] == sys.byteorder:
- flags = flags | NOTSWAPPED
- if not readonly:
- flags = flags | WRITEABLE
- self._setupInterface(data, flags)
- self._pyarray = pyarray
- return
-
-
- def __dealloc__(self):
- """Destructor."""
- return
-
-
- property __array_struct__:
- """Generic array structure property compatible with NumPy, Numeric,
- and numarray."""
- def __get__(self):
- if hasattr(self._pyarray, '__array_struct__'):
- return self._pyarray.__array_struct__
- else:
- Py_INCREF(self)
- obj = PyCObject_FromVoidPtrAndDesc(<void*> self._interface,
- <void*> self,
- interface_destructor)
- return obj
-
-
- def _sizeandtype(self, typestring):
- """Parse typestring into size and type information."""
- assert(8 == sizeof(double))
- assert(4 == sizeof(float))
- assert(4 == sizeof(int))
- info = {'f8': {'size': sizeof(double),
- 'kind': 'f',
- 'type': "double"},
- 'f4': {'size': sizeof(float),
- 'kind': 'f',
- 'type': "float"},
- 'i4': {'size': sizeof(int),
- 'kind': 'i',
- 'type': "int"}}
- if not typestring in info.keys():
- raise ValueError("Unknown C type '%s' in setting up SimplePyArray." \
- % typestring)
- return info[typestring]
-
-# ----------------------------------------------------------------------
-def objAsSimpleArray(obj):
- """
- Test if object is a SimpleArray. If not try to convert it to a
- SimpleArray. If can't convert throw ValueError exception.
- """
- try:
- if not obj.name == "spatialdata_utils_SimpleArray":
- obj = SimplePyArray(obj)
- except AttributeError:
- obj = SimplePyArray(obj)
- return obj
-
-
-# End of file
Deleted: cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe.src
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe.src 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe.src 2009-01-19 04:55:40 UTC (rev 13886)
@@ -1,296 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-
-#header{
-#include "spatialdata/utils/PointsStream.hh"
-
-#include <stdexcept>
-#include <Python.h>
-#}header
-
-# ----------------------------------------------------------------------
-cdef extern from "Python.h":
- object PyCObject_FromVoidPtr(void*, void (*destruct)(void*))
- void* PyCObject_AsVoidPtr(object)
-
-cdef void* ptrFromHandle(obj):
- """Extract pointer from PyCObject."""
- return PyCObject_AsVoidPtr(obj.handle)
-
-cdef extern from "stdlib.h":
- ctypedef unsigned long size_t
-
-cdef void PointStream_destructor(void* obj):
- """
- Destroy PointsStream object.
- """
- #embed{ void PointsStream_destructor_cpp(void* pObj)
- spatialdata::utils::PointsStream* pStream =
- (spatialdata::utils::PointsStream*) pObj;
- delete pStream;
- #}embed
- PointsStream_destructor_cpp(obj)
- return
-
-
-# ----------------------------------------------------------------------
-cdef class PointsStream:
- """
- Wrapper for C++ PointsStream object.
- """
-
- cdef void* thisptr # Pointer to C++ object
- cdef readonly object handle # PyCObject holding pointer to C++ object
- cdef readonly object name # Identifier for object base type
-
- def __init__(self):
- """
- Constructor.
- """
- # create shim for constructor
- #embed{ void* PointsStream_constructor()
- return (void*)(new spatialdata::utils::PointsStream);
- #}embed
- self.thisptr = PointsStream_constructor()
- self.handle = self._createHandle()
- self.name = "spatialdata_utils_PointsStream"
- return
-
- property filename:
- def __set__(self, filename):
- """
- Set name of file.
- """
- # create shim for method 'filename'
- #embed{ void PointsStream_filename_set(void* pObj, char* filename)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->filename(filename);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- PointsStream_filename_set(self.thisptr, filename)
-
- def __get__(self):
- """
- Get name of file.
- """
- # create shim for method 'filename'
- #embed{ char* PointsStream_filename_get(void* pObj)
- char* name = 0;
- try {
- name = (char*) ((spatialdata::utils::PointsStream*) pObj)->filename();
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- return name;
- #}embed
- return PointsStream_filename_get(self.thisptr)
-
-
- property commentFlag:
- def __set__(self, flag):
- """
- Set flag for comment lines.
- """
- # create shim for method 'commentFlag'
- #embed{ void PointsStream_commentFlag_set(void* pObj, char* flag)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->commentFlag(flag);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- PointsStream_commentFlag_set(self.thisptr, flag)
-
- def __get__(self):
- """
- Get flag for comment lines.
- """
- # create shim for method 'commentFlag'
- #embed{ char* PointsStream_commentFlag_get(void* pObj)
- char* name = 0;
- try {
- name = (char*) ((spatialdata::utils::PointsStream*) pObj)->commentFlag();
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- return name;
- #}embed
- return PointsStream_commentFlag_get(self.thisptr)
-
-
- property fieldWidth:
- def __set__(self, width):
- """
- Set field width.
- """
- # create shim for method 'fieldWidth'
- #embed{ void PointsStream_fieldWidth_set(void* pObj, int width)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->fieldWidth(width);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- PointsStream_fieldWidth_set(self.thisptr, width)
-
- def __get__(self):
- """
- Get field width.
- """
- # create shim for method 'fieldWidth'
- #embed{ int PointsStream_fieldWidth_get(void* pObj)
- int width = 0;
- try {
- width = ((spatialdata::utils::PointsStream*) pObj)->fieldWidth();
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- return PointsStream_fieldWidth_get(self.thisptr)
-
-
- property precision:
- def __set__(self, precision):
- """
- Set precision.
- """
- # create shim for method 'precision'
- #embed{ void PointsStream_precision_set(void* pObj, int precision)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->precision(precision);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- PointsStream_precision_set(self.thisptr, precision)
-
- def __get__(self):
- """
- Get flag for comment lines.
- """
- # create shim for method 'precision'
- #embed{ int PointsStream_precision_get(void* pObj)
- int precision = 0;
- try {
- precision = ((spatialdata::utils::PointsStream*) pObj)->precision();
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- return precision;
- #}embed
- return PointsStream_precision_get(self.thisptr)
-
-
- def read(self):
- """
- Read points from stdin.
- """
- # create shim for method 'read'
- #embed{ void PointsStream_read(void* pObj, double** ppVals, int* pNumPts, int* pNumDims)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->read(ppVals,
- pNumPts, pNumDims);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
- cdef double* pVals
- cdef int numPts
- cdef int numDims
- pVals = NULL
- numPts = 0
- numDims = 0
- PointsStream_read(self.thisptr, &pVals, &numPts, &numDims)
- dims = [numPts, numDims]
- import spatialdata.utils.simplearray
- pValsObj = PyCObject_FromVoidPtr(pVals, NULL);
- return spatialdata.utils.simplearray.SimpleCppArray(pValsObj,
- dims, "double")
-
-
- def write(self, points):
- """
- Write points to stdout.
- """
- # create shim for method 'write'
- #embed{ void PointsStream_write(void* pObj, double* pVals, int numPts, int numDims)
- try {
- ((spatialdata::utils::PointsStream*) pObj)->write(pVals, numPts, numDims);
- } catch (const std::exception& err) {
- PyErr_SetString(PyExc_RuntimeError,
- const_cast<char*>(err.what()));
- } catch (...) {
- PyErr_SetString(PyExc_RuntimeError,
- "Caught unknown C++ exception.");
- } // try/catch
- #}embed
-
- import spatialdata.utils.simplearray
- points = spatialdata.utils.simplearray.objAsSimpleArray(points)
- if not points.isCompatible(nd=2,
- simpletype="double",
- contiguous=True,
- notswapped=True):
- raise TypeError, \
- "Argument 'points' must be a contiguous, 2-D array of type double."
-
- (numPts, numDims) = points.shape
- cdef double* pVals
- pVals = <double*> PyCObject_AsVoidPtr(points.data)
- PointsStream_write(self.thisptr, pVals, numPts, numDims)
- return
-
-
- def _createHandle(self):
- """Wrap pointer to C++ object in PyCObject."""
- # create shim for destructor
- return PyCObject_FromVoidPtr(self.thisptr, PointStream_destructor)
-
-
-# End of file
Modified: cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/Makefile.am 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/Makefile.am 2009-01-19 04:55:40 UTC (rev 13886)
@@ -28,7 +28,7 @@
TestGravityField.py \
TestSCECCVMH.py \
TestSimpleIOAscii.py \
- TestSpatialDB.py \
+ TestSimpleDB.py \
TestUniformDB.py
dist_noinst_PYTHON = \
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/Makefile.am 2009-01-19 04:55:40 UTC (rev 13886)
@@ -20,43 +20,12 @@
noinst_PYTHON = \
TestChangeCoordSys.py \
- TestConvertApp.py \
- TestPointsStream.py \
- TestSimpleArray.py
+ TestConvertApp.py
data_TMP = in.txt out.txt
-# module
-subpkgpyexec_LTLIBRARIES = testcppmodule.la
-testcppmodule_la_LDFLAGS = -module -avoid-version \
- $(AM_LDFLAGS) $(PYTHON_LA_LDFLAGS)
-testcppmodule_la_LIBADD =
-if NO_UNDEFINED
-testcppmodule_la_LIBADD += \
- $(PYTHON_BLDLIBRARY) $(PYTHON_LIBS) $(PYTHON_SYSLIBS)
-endif
+CLEANFILES = $(data_TMP)
-dist_testcppmodule_la_SOURCES = testcpp.pyxe.src
-nodist_testcppmodule_la_SOURCES = \
- testcpp.pyxe \
- testcpp.c testcpp_embed.cpp testcpp_embed.h
-
-INCLUDES += -I$(PYTHON_INCDIR)
-
-testcpp.pyx testcpp_embed.cpp testcpp_embed.h: 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.pyxe testcpp.pyx testcpp.c *_embed.*
-CLEANFILES += $(data_TMP)
-
-
# End of file
Deleted: cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src 2009-01-19 03:57:58 UTC (rev 13885)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe.src 2009-01-19 04:55:40 UTC (rev 13886)
@@ -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
More information about the CIG-COMMITS
mailing list