File: test_Variable.py

package info (click to toggle)
cf-python 1.3.2+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 7,996 kB
  • sloc: python: 51,733; ansic: 2,736; makefile: 78; sh: 2
file content (41 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import numpy
import cf
import unittest
import inspect

class VariableTest(unittest.TestCase):
    def setUp(self):
        self.filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                     'test_file.nc')
        self.chunk_sizes = (17, 34, 300, 100000)[::-1]
        self.original_chunksize = cf.CHUNKSIZE()
        self.f = cf.read(self.filename)[0]
        self.test_only = ()

    def test_Variable_max_mean_mid_range_min_range_sd_sum_var(self):    
        if self.test_only and inspect.stack()[0][3] not in self.test_only:
            return
            
        for chunksize in self.chunk_sizes:            
            f = cf.read(self.filename)[0]

            self.assertTrue(f.max()       == f.data.max(squeeze=True))
            self.assertTrue(f.mean()      == f.data.mean(squeeze=True))
            self.assertTrue(f.mid_range() == f.data.mid_range(squeeze=True))
            self.assertTrue(f.min()       == f.data.min(squeeze=True))
            self.assertTrue(f.range()     == f.data.range(squeeze=True))
            self.assertTrue(f.sd()        == f.data.sd(squeeze=True))
            self.assertTrue(f.sum()       == f.data.sum(squeeze=True))
            self.assertTrue(f.var()       == f.data.var(squeeze=True))
        #--- End: for    
        cf.CHUNKSIZE(self.original_chunksize)
    #--- End: def
        
#--- End: class
        
if __name__ == '__main__':
    print 'cf-python version:', cf.__version__
    print 'cf-python path:'   , os.path.abspath(cf.__file__)
    print''
    unittest.main(verbosity=2)