[cig-commits] r4110 - in cs/spatialdata-0.1/trunk: applications
libsrc/utils modulesrc/geocoords modulesrc/spatialdb
modulesrc/utils spatialdata/geocoords spatialdata/utils
tests/pytests/spatialdb tests/pytests/utils
baagaard at geodynamics.org
baagaard at geodynamics.org
Wed Jul 26 13:05:05 PDT 2006
Author: baagaard
Date: 2006-07-26 13:05:05 -0700 (Wed, 26 Jul 2006)
New Revision: 4110
Added:
cs/spatialdata-0.1/trunk/applications/pyconvert.py
cs/spatialdata-0.1/trunk/spatialdata/utils/ConvertApp.py
cs/spatialdata-0.1/trunk/tests/pytests/utils/TestChangeCoordSys.py
Removed:
cs/spatialdata-0.1/trunk/applications/pyconvert.py
Modified:
cs/spatialdata-0.1/trunk/libsrc/utils/PointsStream.cc
cs/spatialdata-0.1/trunk/modulesrc/geocoords/geocoords.pyxe
cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe
cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe
cs/spatialdata-0.1/trunk/spatialdata/geocoords/Converter.py
cs/spatialdata-0.1/trunk/spatialdata/utils/ChangeCoordSys.py
cs/spatialdata-0.1/trunk/spatialdata/utils/PointsStream.py
cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSpatialDB.py
cs/spatialdata-0.1/trunk/tests/pytests/utils/TestPointsStream.py
cs/spatialdata-0.1/trunk/tests/pytests/utils/TestSimpleArray.py
cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe
cs/spatialdata-0.1/trunk/tests/pytests/utils/testutils.py
Log:
Added use of objAsSimpleArray() to permit transparent passing of numpy arrays from Python. Adjusted module source to use PyCObjects in SimpleCppArray().
Deleted: cs/spatialdata-0.1/trunk/applications/pyconvert.py
===================================================================
--- cs/spatialdata-0.1/trunk/applications/pyconvert.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/applications/pyconvert.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-#
-# ======================================================================
-#
-# Brad T. Aagaard
-# U.S. Geological Survey
-#
-# {LicenseText}
-#
-# ======================================================================
-#
-
-## @file applications/pyconvert.py
-## @brief Python convert application driver
-
-from pyre.components.Component import Component
-# Dummy class for empty component
-class Dummy(Component):
- def __init__(self):
- Component.__init__(self, name="dummy", facility="dummy")
- return
-
-from pyre.applications.Script import Script
-# Convert class
-class Convert(Script):
- """
- Python Convert application driver.
- """
-
- # INVENTORY //////////////////////////////////////////////////////////
-
- class Inventory(Script.Inventory):
- """
- Python object for managing Convert facilities and properties.
- """
-
- ## @class Inventory
- ## Python object for managing Convert facilities and properties.
- ##
- ## \b Properties
- ## @li None
- ##
- ## \b Facilities
- ## @li \b unpickler Unpickler to load data
- ## @li \b converter Converter to convert data
- ## @li \b pickler Pickler to dump data
-
- import pyre.inventory
-
- reader = pyre.inventory.facility("reader", factory=Dummy)
- reader.meta['tip'] = "Reader to load data."
-
- converter = pyre.inventory.facility("converter", factory=Dummy)
- converter.meta['tip'] = "Converter to convert data."
-
- writer = pyre.inventory.facility("writer", factory=Dummy)
- writer.meta['tip'] = "Writer to dump data."
-
- # PUBLIC METHODS /////////////////////////////////////////////////////
-
- def main(self, *args, **kwds):
- """
- Main entry point for application.
- """
- data = self.reader.read()
- if not self.converter is None:
- self.converter.convert(data)
- self.writer.write(data)
- return
-
-
- def __init__(self):
- """
- Constructor.
- """
- Script.__init__(self, 'pyconvert')
- return
-
-
- # PRIVATE METHODS ////////////////////////////////////////////////////
-
- def _configure(self):
- """
- Set members using inventory.
- """
-
- Script._configure(self)
- if self.inventory.reader.name == "dummy":
- raise UnboundLocalError, "convert needs a reader to load the data.\n" \
- "Please specify an unpickler with --reader=myreader"
- else:
- self.reader = self.inventory.reader
-
- if self.inventory.converter.name == "dummy":
- self.converter = None
- else:
- self.converter = self.inventory.converter
-
- if self.inventory.writer.name == "dummy":
- self.writer = self.reader
- else:
- self.writer = self.inventory.writer
-
- return
-
-
-# ----------------------------------------------------------------------
-if __name__ == '__main__':
-
- app = Convert()
- app.run()
-
-
-# End of file
Added: cs/spatialdata-0.1/trunk/applications/pyconvert.py
===================================================================
--- cs/spatialdata-0.1/trunk/applications/pyconvert.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/applications/pyconvert.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file spatialdata/applications/pyconvert.py
+## @brief Generic use of ConvertApp.
+
+# ----------------------------------------------------------------------
+if __name__ == '__main__':
+ from spatialdata.utils.ConvertApp import ConvertApp
+
+ app = ConvertApp()
+ app.run()
+
+
+# End of file
Modified: cs/spatialdata-0.1/trunk/libsrc/utils/PointsStream.cc
===================================================================
--- cs/spatialdata-0.1/trunk/libsrc/utils/PointsStream.cc 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/libsrc/utils/PointsStream.cc 2006-07-26 20:05:05 UTC (rev 4110)
@@ -63,6 +63,8 @@
if (pIn->good())
++numPts;
} // while
+ if (&std::cin != pIn)
+ delete pIn;
if (0 != ppPoints) {
const size_t size = numPts * numDims;
@@ -75,8 +77,6 @@
*pNumPts = numPts;
if (0 != pNumDims)
*pNumDims = numDims;
- if (&std::cin != pIn)
- delete pIn;
} // read
// ----------------------------------------------------------------------
Modified: cs/spatialdata-0.1/trunk/modulesrc/geocoords/geocoords.pyxe
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/geocoords/geocoords.pyxe 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/modulesrc/geocoords/geocoords.pyxe 2006-07-26 20:05:05 UTC (rev 4110)
@@ -431,9 +431,8 @@
"""Convert coordinates from source coordinate system 'csSrc' to
destination coordinate system 'csDest'."""
- if not coordsSrc.name == "spatialdata_utils_SimpleArray":
- raise TypeError, \
- "Argument 'coordsSrc' must be of type 'SimpleArray'."
+ import spatialdata.utils.simplearray
+ coordsSrc = spatialdata.utils.simplearray.objAsSimpleArray(coordsSrc)
if not coordsSrc.isCompatible(nd=2,
simpletype="double",
writeable=True,
Modified: cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/modulesrc/spatialdb/spatialdb.pyxe 2006-07-26 20:05:05 UTC (rev 4110)
@@ -129,9 +129,8 @@
pCS);
#}embed
- if not locs.name == "spatialdata_utils_SimpleArray":
- raise TypeError, \
- "Argument 'locs' must be of type 'SimpleArray'."
+ import spatialdata.utils.simplearray
+ locs = spatialdata.utils.simplearray.objAsSimpleArray(locs)
if not locs.isCompatible(nd=2,
simpletype="double",
contiguous=True,
@@ -171,7 +170,9 @@
dims = [nlocs, nvals]
import spatialdata.utils.simplearray
- return spatialdata.utils.simplearray.SimpleCppArray(<object> pVals, dims, "double")
+ pValsObj = PyCObject_FromVoidPtr(pVals, NULL);
+ return spatialdata.utils.simplearray.SimpleCppArray(pValsObj,
+ dims, "double")
def _createHandle(self):
Modified: cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe
===================================================================
--- cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/modulesrc/utils/utils.pyxe 2006-07-26 20:05:05 UTC (rev 4110)
@@ -39,8 +39,12 @@
"""
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.thisptr = NULL
self.name = "spatialdata_utils_PointsStream"
return
@@ -89,7 +93,7 @@
property fieldWidth:
- def __set__(self, flag):
+ def __set__(self, width):
"""
Set field width.
"""
@@ -111,7 +115,7 @@
property precision:
- def __set__(self, flag):
+ def __set__(self, precision):
"""
Set precision.
"""
@@ -148,9 +152,10 @@
numPts = 0
numDims = 0
PointsStream_read(self.thisptr, &pVals, &numPts, &numDims)
+ dims = [numPts, numDims]
import spatialdata.utils.simplearray
- dims = [numPts, numDims]
- return spatialdata.utils.simplearray.SimpleCppArray(<object> pVals,
+ pValsObj = PyCObject_FromVoidPtr(pVals, NULL);
+ return spatialdata.utils.simplearray.SimpleCppArray(pValsObj,
dims, "double")
@@ -162,14 +167,14 @@
#embed{ void PointsStream_write(void* pObj, double* pVals, int numPts, int numDims)
((spatialdata::utils::PointsStream*) pObj)->write(pVals, numPts, numDims);
#}embed
- if not points.name == "spatialdata_utils_SimpleArray":
+
+ 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 'coordsSrc' must be of type 'SimpleArray'."
- if not coordsSrc.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
Modified: cs/spatialdata-0.1/trunk/spatialdata/geocoords/Converter.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/geocoords/Converter.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/spatialdata/geocoords/Converter.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -17,11 +17,8 @@
"""Convert coordinates from source coordinate system to destination
coordinate system. Transformation is done in place."""
- import spatialdata.utils.simplearray as simplearray
- coordsSrcArray = simplearray.SimplePyArray(coordsSrc)
-
import spatialdata.geocoords.geocoords as bindings
- bindings.Converter_convert(coordsSrcArray, csDest.cppHandle, csSrc.cppHandle)
+ bindings.Converter_convert(coordsSrc, csDest.cppHandle, csSrc.cppHandle)
return
Modified: cs/spatialdata-0.1/trunk/spatialdata/utils/ChangeCoordSys.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/utils/ChangeCoordSys.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/spatialdata/utils/ChangeCoordSys.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -29,7 +29,7 @@
"""
## @class Inventory
- ## Python object for managing ConvertMeshVertices facilities
+ ## Python object for managing ChangeCoordSys facilities
## and properties.
##
## \b Properties
@@ -52,32 +52,21 @@
# PUBLIC METHODS /////////////////////////////////////////////////////
- def initialize(self):
- """
- Initialize converter.
- """
- self.csSrc.initialize()
- self.csDest.initialize()
- return
-
-
def convert(self, points):
"""
- Convert coordinates of vertices.
+ Transform coordinates of points from one coordinate system to another.
"""
-
- self.initialize()
-
+ self._initialize()
from spatialdata.geocoords.Converter import convert
convert(points, self.csDest, self.csSrc)
return
- def __init__(self, name="convertcs"):
+ def __init__(self, name="changecoordsys"):
"""
Constructor.
"""
- Converter.__init__(self, name)
+ Component.__init__(self, name, facility="converter")
return
@@ -87,10 +76,18 @@
"""
Set members from inventory.
"""
-
self.csDest = self.inventory.csDest
self.csSrc = self.inventory.csSrc
return
+ def _initialize(self):
+ """
+ Initialize converter.
+ """
+ self.csSrc.initialize()
+ self.csDest.initialize()
+ return
+
+
# End of file
Copied: cs/spatialdata-0.1/trunk/spatialdata/utils/ConvertApp.py (from rev 4108, cs/spatialdata-0.1/trunk/applications/pyconvert.py)
===================================================================
--- cs/spatialdata-0.1/trunk/applications/pyconvert.py 2006-07-26 03:58:56 UTC (rev 4108)
+++ cs/spatialdata-0.1/trunk/spatialdata/utils/ConvertApp.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+## @file spatialdata/utils/pyconvert.py
+## @brief Python convert application driver
+
+from pyre.components.Component import Component
+# Dummy class for empty component
+class Dummy(Component):
+ def __init__(self):
+ Component.__init__(self, name="dummy", facility="dummy")
+ return
+
+from pyre.applications.Script import Script
+# ConvertApp class
+class ConvertApp(Script):
+ """
+ Python Convert application driver.
+ """
+
+ # INVENTORY //////////////////////////////////////////////////////////
+
+ class Inventory(Script.Inventory):
+ """
+ Python object for managing ConvertApp facilities and properties.
+ """
+
+ ## @class Inventory
+ ## Python object for managing ConvertApp facilities and properties.
+ ##
+ ## \b Properties
+ ## @li None
+ ##
+ ## \b Facilities
+ ## @li \b unpickler Unpickler to load data
+ ## @li \b converter Converter to convert data
+ ## @li \b pickler Pickler to dump data
+
+ import pyre.inventory
+
+ reader = pyre.inventory.facility("reader", factory=Dummy)
+ reader.meta['tip'] = "Reader to load data."
+
+ converter = pyre.inventory.facility("converter", factory=Dummy)
+ converter.meta['tip'] = "Converter to convert data."
+
+ writer = pyre.inventory.facility("writer", factory=Dummy)
+ writer.meta['tip'] = "Writer to dump data."
+
+ # PUBLIC METHODS /////////////////////////////////////////////////////
+
+ def main(self, *args, **kwds):
+ """
+ Main entry point for application.
+ """
+ data = self.reader.read()
+ if not self.converter is None:
+ self.converter.convert(data)
+ self.writer.write(data)
+ return
+
+
+ def __init__(self):
+ """
+ Constructor.
+ """
+ Script.__init__(self, 'pyconvert')
+ return
+
+
+ # PRIVATE METHODS ////////////////////////////////////////////////////
+
+ def _configure(self):
+ """
+ Set members using inventory.
+ """
+
+ Script._configure(self)
+ if self.inventory.reader.name == "dummy":
+ raise UnboundLocalError, "convert needs a reader to load the data.\n" \
+ "Please specify an unpickler with --reader=myreader"
+ else:
+ self.reader = self.inventory.reader
+
+ if self.inventory.converter.name == "dummy":
+ self.converter = None
+ else:
+ self.converter = self.inventory.converter
+
+ if self.inventory.writer.name == "dummy":
+ self.writer = self.reader
+ else:
+ self.writer = self.inventory.writer
+
+ return
+
+
+# End of file
Modified: cs/spatialdata-0.1/trunk/spatialdata/utils/PointsStream.py
===================================================================
--- cs/spatialdata-0.1/trunk/spatialdata/utils/PointsStream.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/spatialdata/utils/PointsStream.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -31,18 +31,21 @@
## @class Inventory
## Python object for managing PointsStream facilities and properties.
##
- ## \b Properties (input)
- ## @li \b commentFlag String identifying comment.
+ ## \b Properties
+ ## @li \b filename Name of file for input/output
+ ## (default is to use stdin/stdout).
+ ## @li \b commentFlag String identifying comment (input).
+ ## @li \b field_width Width of field for coordinates (output).
+ ## @li \b precision Decimnal precision of coordinates (output).
##
- ## \b Properties (output)
- ## @li \b field_width Width of field for coordinates
- ## @li \b precision Decimnal precision of coordinates
- ##
## \b Facilities
## @li None
import pyre.inventory
+ filename = pyre.inventory.str("filename", default="")
+ filename.meta['tip'] = "Name of file for input/output."
+
commentFlag = pyre.inventory.str("comment_flag", default="#")
commentFlag.meta['tip'] = "String identifying comment."
@@ -82,6 +85,7 @@
Component.__init__(self, name, facility="pointsstream")
import spatialdata.utils.utils as bindings
self.cppHandle = bindings.PointsStream()
+ self.filename = ""
self.commentFlag = "#"
self.fieldWidth = 14
self.precision = 5
@@ -104,6 +108,7 @@
"""
Synchronize with C++ object.
"""
+ self.cppHandle.filename = self.filename
self.cppHandle.commentFlag = self.commentFlag
self.cppHandle.fieldWidth = self.fieldWidth
self.cppHandle.precision = self.precision
Modified: cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSpatialDB.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSpatialDB.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/spatialdb/TestSpatialDB.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -12,7 +12,7 @@
import unittest
-import numpy as numeric
+import numpy
import spatialdata.utils.simplearray as simplearray
from spatialdata.geocoords.CSCart import CSCart
@@ -36,18 +36,18 @@
self._db.open()
self._db.queryVals(["two", "one"])
- locs = numeric.array( [[1.0, 2.0, 3.0],
- [5.6, 4.2, 8.6]], numeric.Float64)
+ locs = numpy.array( [[1.0, 2.0, 3.0],
+ [5.6, 4.2, 8.6]],
+ numpy.Float64)
cs = CSCart()
cs.toMeters = 1.0
- valsE = numeric.array( [[4.7, 6.3]]*2, numeric.Float64)
- vals = numeric.array(self._db.query(simplearray.SimplePyArray(locs),
- cs, 2))
+ valsE = numpy.array( [[4.7, 6.3]]*2, numpy.Float64)
+ vals = numpy.array(self._db.query(locs, cs, 2))
self.assertEqual(2, len(vals.shape))
for dE, d in zip(valsE.shape, vals.shape):
self.assertEqual(dE, d)
- for vE, v in zip(numeric.reshape(valsE, -1), numeric.reshape(vals, -1)):
+ for vE, v in zip(numpy.reshape(valsE, -1), numpy.reshape(vals, -1)):
self.assertAlmostEqual(vE, v, 6)
self._db.close()
Added: cs/spatialdata-0.1/trunk/tests/pytests/utils/TestChangeCoordSys.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/TestChangeCoordSys.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/TestChangeCoordSys.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# ======================================================================
+#
+# Brad T. Aagaard
+# U.S. Geological Survey
+#
+# {LicenseText}
+#
+# ======================================================================
+#
+
+import unittest
+
+import numpy
+
+lonlatNAD27ElevVals = numpy.array([
+ [ -1.150000000000e+02, 3.900000000000e+01, 1.200000000000e+01],
+ [ -1.203425320000e+02, 4.323423000000e+01, 1.010000000000e+01],
+ [ -1.213425320000e+02, 4.523423000000e+01, 3.600000000000e+00],
+ [ -1.153425320000e+02, 3.623423000000e+01, 7.200000000000e+00],
+ [ -1.103425320000e+02, 3.923423000000e+01, 1.233000000000e+02],
+ [ -1.073425320000e+02, 3.323423000000e+01, 3.460000000000e+01] ],
+ numpy.Float64)
+xyzLocalVals = numpy.array([
+ [ -1.284640403035e+06, 1.064304545254e+05, -1.314223692642e+05],
+ [ -1.617989794934e+06, 6.524818198322e+05, -2.429529282853e+05],
+ [ -1.637488936891e+06, 8.852730256818e+05, -2.774331803783e+05],
+ [ -1.362847273202e+06, -1.913287267443e+05, -1.500646063011e+05],
+ [ -8.881745585536e+05, 7.658679833419e+04, -6.239199171253e+04],
+ [ -6.825105927499e+05, -6.111332573069e+05, -6.615476872030e+04] ],
+ numpy.Float64)
+
+
+class TestChangeCoordSys(unittest.TestCase):
+
+
+ def test_convert(self):
+ """
+ Test convert().
+ """
+ from spatialdata.geocoords.CSGeo import CSGeo
+ csNAD27 = CSGeo()
+ csNAD27.ellipsoid = "clrk66"
+ csNAD27.datumHoriz = "NAD27"
+ csNAD27.datumVert = "mean sea level"
+
+ from spatialdata.geocoords.CSGeoLocalCart import CSGeoLocalCart
+ csLocal = CSGeoLocalCart()
+ csLocal.originLon = -100.0
+ csLocal.originLat = 39.0
+ from pyre.units.length import m
+ csLocal.originElev = 0.01*m
+ csLocal.ellipsoid = "clrk66"
+ csLocal.datumHoriz = "NAD27"
+ csLocal.datumVert = "mean sea level"
+
+ from spatialdata.utils.ChangeCoordSys import ChangeCoordSys
+ converter = ChangeCoordSys()
+ converter.csDest = csLocal
+ converter.csSrc = csNAD27
+ coordsXYZ = lonlatNAD27ElevVals
+ converter.convert(coordsXYZ)
+ xyzLocalValsT = numpy.array(coordsXYZ)
+
+ self.assertEqual(len(xyzLocalVals.shape), len(xyzLocalValsT.shape))
+ for (xyz, xyzT) in zip(numpy.reshape(xyzLocalVals,-1),
+ numpy.reshape(xyzLocalValsT, -1)):
+ self.assertAlmostEqual(1.0, xyz/xyzT, 6)
+ return
+
+
+# End of file
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/TestPointsStream.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/TestPointsStream.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/TestPointsStream.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -55,15 +55,12 @@
[1.1, 2.1, 3.1],
[1.2, 2.2, 3.2] ],
numpy.Float64)
-
filename = "tmp.txt"
s = PointsStream()
- print "AA"
+ s.filename = filename
s.write(pointsE)
- print "BB"
points = s.read()
- print "CC"
self.assertEqual(len(pointsE.shape), len(points.shape))
for dE,d in zip(pointsE.shape, points.shape):
self.assertEqual(dE, d)
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/TestSimpleArray.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/TestSimpleArray.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/TestSimpleArray.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -12,7 +12,7 @@
import unittest
-import numpy as numeric
+import numpy
import spatialdata.utils.simplearray as simplearray
class TestSimpleArray(unittest.TestCase):
@@ -20,38 +20,38 @@
def test_frompy(self):
vals = [1.1, 2.1, 3.1, 1.2, 2.2, 3.2]
- x = numeric.array(vals, numeric.Float64)
+ x = numpy.array(vals, numpy.Float64)
y = simplearray.SimplePyArray(x)
self.assertEqual(len(x.shape), y.nd)
self.assertEqual(len(x.shape), len(y.shape))
for dE,d in zip(x.shape, y.shape):
self.assertEqual(dE, d)
- z = numeric.array(y)
+ z = numpy.array(y)
for vE, v in zip(vals, z):
self.assertAlmostEqual(vE, v, 6)
vals = [ [1, 2, 3],
[4, 5, 6] ]
- x = numeric.array(vals, numeric.Int32)
+ x = numpy.array(vals, numpy.Int32)
y = simplearray.SimplePyArray(x)
self.assertEqual(len(x.shape), y.nd)
self.assertEqual(len(x.shape), len(y.shape))
for dE,d in zip(x.shape, y.shape):
self.assertEqual(dE, d)
- z = numeric.array(y)
- for vE,v in zip(numeric.reshape(vals, -1), numeric.reshape(z, -1)):
+ z = numpy.array(y)
+ for vE,v in zip(numpy.reshape(vals, -1), numpy.reshape(z, -1)):
self.assertEqual(vE, v)
vals = [ [ [1.1, 2.1, 3.1] ],
[ [2.1, 2.2, 3.2] ] ]
- x = numeric.array(vals, numeric.Float32)
+ x = numpy.array(vals, numpy.Float32)
y = simplearray.SimplePyArray(x)
self.assertEqual(len(x.shape), y.nd)
self.assertEqual(len(x.shape), len(y.shape))
for dE,d in zip(x.shape, y.shape):
self.assertEqual(dE, d)
- z = numeric.array(y)
- for vE,v in zip(numeric.reshape(vals, -1), numeric.reshape(z, -1)):
+ z = numpy.array(y)
+ for vE,v in zip(numpy.reshape(vals, -1), numpy.reshape(z, -1)):
self.assertAlmostEqual(vE, v, 4)
return
@@ -59,15 +59,15 @@
def test_fromcpp(self):
vals = [ [1.1, 2.1, 3.1],
[1.2, 2.2, 3.2] ]
- x = numeric.array(vals, numeric.Float64)
+ x = numpy.array(vals, numpy.Float64)
import spatialdata.utils.testcpp as testcpp
y = testcpp.cpparray()
self.assertEqual(len(x.shape), y.nd)
self.assertEqual(len(x.shape), len(y.shape))
for dE,d in zip(x.shape, y.shape):
self.assertEqual(dE, d)
- z = numeric.array(y)
- for vE,v in zip(numeric.reshape(vals, -1), numeric.reshape(z, -1)):
+ z = numpy.array(y)
+ for vE,v in zip(numpy.reshape(vals, -1), numpy.reshape(z, -1)):
self.assertAlmostEqual(vE, v, 4)
return
@@ -76,7 +76,7 @@
vals = [ [1.1, 2.1],
[1.2, 2.2],
[1.3, 2.3] ]
- x = numeric.array(vals, numeric.Float64)
+ x = numpy.array(vals, numpy.Float64)
import spatialdata.utils.testcpp as testcpp
try:
testcpp.test(simplearray.SimplePyArray(x))
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/testcpp.pyxe 2006-07-26 20:05:05 UTC (rev 4110)
@@ -14,6 +14,7 @@
double fabs(double)
cdef extern from "Python.h":
+ object PyCObject_FromVoidPtr(void*, void (*func)(void*))
void* PyCObject_AsVoidPtr(object)
def cpparray():
@@ -33,7 +34,8 @@
pData = NULL
cpparray_create(&pData, &size)
dims = [2, 3]
- return spatialdata.utils.simplearray.SimpleCppArray(<object> pData, dims, "double")
+ pDataObj = PyCObject_FromVoidPtr(pData, NULL);
+ return spatialdata.utils.simplearray.SimpleCppArray(pDataObj, dims, "double")
def test(sarray):
Modified: cs/spatialdata-0.1/trunk/tests/pytests/utils/testutils.py
===================================================================
--- cs/spatialdata-0.1/trunk/tests/pytests/utils/testutils.py 2006-07-26 20:04:02 UTC (rev 4109)
+++ cs/spatialdata-0.1/trunk/tests/pytests/utils/testutils.py 2006-07-26 20:05:05 UTC (rev 4110)
@@ -19,6 +19,9 @@
from TestSimpleArray import TestSimpleArray
suite.addTest(unittest.makeSuite(TestSimpleArray))
+ from TestChangeCoordSys import TestChangeCoordSys
+ suite.addTest(unittest.makeSuite(TestChangeCoordSys))
+
from TestPointsStream import TestPointsStream
suite.addTest(unittest.makeSuite(TestPointsStream))
More information about the cig-commits
mailing list