/[escript]/trunk/escript/test/python/run_xml.py
ViewVC logotype

Diff of /trunk/escript/test/python/run_xml.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2344 by jfenwick, Mon Mar 30 02:13:58 2009 UTC revision 2455 by jfenwick, Wed Jun 3 03:29:07 2009 UTC
# Line 24  from esys.escript.modelframe import Mode Line 24  from esys.escript.modelframe import Mode
24  import math  import math
25  from cStringIO import StringIO  from cStringIO import StringIO
26  from xml.dom import minidom  from xml.dom import minidom
27  import numarray  import numpy
28    import sys
29    
30  class XMLDocumentTestCase(unittest.TestCase):  class XMLDocumentTestCase(unittest.TestCase):
31    
# Line 213  class ParamaterSetTestCase(unittest.Test Line 214  class ParamaterSetTestCase(unittest.Test
214    
215      def testFromDomNumarrayVector(self):      def testFromDomNumarrayVector(self):
216          p3 = ParameterSet()          p3 = ParameterSet()
217          mynumarray = numarray.array([3., 4., 5.], type=numarray.Float64)          mynumpy = numpy.array([3., 4., 5.], dtype=numpy.float64)
218          p3.declareParameter(numtest=mynumarray)          p3.declareParameter(numtest=mynumpy)
219          doc = self._class(p3)          doc = self._class(p3)
220          assert doc.numtest.type() == numarray.Float64          assert doc.numtest.dtype == numpy.float64
221          assert type(doc.numtest) == numarray.NumArray          assert type(doc.numtest) == numpy.ndarray
222    
223      def testFromDomNumarrayMulti(self):      def testFromDomNumarrayMulti(self):
224          p3 = ParameterSet()          p3 = ParameterSet()
225          mynumarray = numarray.array([[1., 2., 3.], [3., 4., 5.]], type=numarray.Float64)          mynumpy = numpy.array([[1., 2., 3.], [3., 4., 5.]], dtype=numpy.float64)
226          p3.declareParameter(numtest=mynumarray)          p3.declareParameter(numtest=mynumpy)
227          doc = self._class(p3)          doc = self._class(p3)
228          assert doc.numtest.type() == numarray.Float64          assert doc.numtest.dtype == numpy.float64
229          assert type(doc.numtest) == numarray.NumArray          assert type(doc.numtest) == numpy.ndarray
230    
231      def testBoolLists(self):  # This method is disabled until the correct behaviour for lists of bools is decided
232          p4 = ParameterSet()  #numarray converts them into ints whereas numpy leaves them as bools
233          mylist = [True, False, False, True]      #def testBoolLists(self):
234          p4.declareParameter(listest=mylist)          #p4 = ParameterSet()
235          doc = self._class(p4)          #mylist = [True, False, False, True]
236          assert type(doc.listest) == numarray.NumArray          #p4.declareParameter(listest=mylist)
237          assert doc.listest.type() == numarray.Bool          #doc = self._class(p4)
238          assert len(doc.listest) == len(mylist)          #assert type(doc.listest) == numpy.ndarray
239          assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])          #assert doc.listest.type() == numpy.bool_
240            #assert len(doc.listest) == len(mylist)
241            #assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])
242    
243      def testIntLists(self):      def testIntLists(self):
244          p4 = ParameterSet()          p4 = ParameterSet()
245          mylist = [1,2,4]          mylist = [1,2,4]
246          p4.declareParameter(listest=mylist)          p4.declareParameter(listest=mylist)
247          doc = self._class(p4)          doc = self._class(p4)
248          assert type(doc.listest) == numarray.NumArray          assert type(doc.listest) == numpy.ndarray
249          assert doc.listest.type() == numarray.Int          assert doc.listest.dtype == numpy.int_
250          assert len(doc.listest) == len(mylist)          assert len(doc.listest) == len(mylist)
251          assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])          assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])
252    
# Line 252  class ParamaterSetTestCase(unittest.Test Line 255  class ParamaterSetTestCase(unittest.Test
255          mylist = [1.,2.,4.]          mylist = [1.,2.,4.]
256          p4.declareParameter(listest=mylist)          p4.declareParameter(listest=mylist)
257          doc = self._class(p4)          doc = self._class(p4)
258          assert type(doc.listest) == numarray.NumArray          assert type(doc.listest) == numpy.ndarray
259          assert doc.listest.type() == numarray.Float          assert doc.listest.dtype == numpy.float_
260          assert len(doc.listest) == len(mylist)          assert len(doc.listest) == len(mylist)
261          assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])          assert min([ mylist[i] == doc.listest[i] for i in range(len( doc.listest)) ])
262    

Legend:
Removed from v.2344  
changed lines
  Added in v.2455

  ViewVC Help
Powered by ViewVC 1.1.26