/[escript]/trunk/escriptcore/test/python/test_util_NaN_funcs.py
ViewVC logotype

Contents of /trunk/escriptcore/test/python/test_util_NaN_funcs.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 8 months ago) by sshaw
File MIME type: text/x-python
File size: 1765 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2015 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import print_function, division
18
19 #here be nan tests
20 import esys.escript as es
21 import esys.escriptcore.utestselect as unittest
22
23 class Test_util_NaN_funcs(unittest.TestCase):
24 RES_TOL=1.e-7 # RES_TOLerance to compare results
25 DIFF_TOL=1.e-7 # RES_TOLerance to derivatives
26
27 def test_replaceNaNExpanded(self):
28 dom=self.domain
29 scl=es.Scalar(0,es.ContinuousFunction(dom))
30 scl.expand()
31 sclNaN=scl/0
32 self.assertTrue(sclNaN.hasNaN(),"sclNaN should contain NaN but its doesn't")
33 sclNaN.replaceNaN(15.0)
34 self.assertEqual(es.Lsup(sclNaN), 15.0)
35
36 def test_replaceNaNConstant(self):
37 dom=self.domain
38 dat = es.Data(10,es.ContinuousFunction(dom))
39 dat=(dat*0)/0
40 self.assertTrue(dat.hasNaN(),"dat should contain NaN but its doesn't")
41 dat.replaceNaN(10)
42 self.assertEqual(es.Lsup(dat), 10)
43
44 def test_replaceNaNTagged(self):
45 dom=self.domain
46 sigma = es.Scalar(0,es.FunctionOnBoundary(dom))
47 dat=(sigma*0)/0
48 sigma.setTaggedValue(1 , es.Lsup(dat))
49 sigma.replaceNaN(10)
50 self.assertEqual(es.Lsup(sigma), 10)

  ViewVC Help
Powered by ViewVC 1.1.26