Debian Codegraph @

nxs/test/napi/test_constants.py

raw
1 """@package nxs
2 Python NeXus interface.
3
4 NeXus_ is a common data format for neutron, Xray and muon science.
5 The files contain multidimensional data elements grouped into a
6 hierarchical structure. The data sets are self-describing, with
7 a description of the instrument configuration including the units
8 used as well as the data measured.
9
10 The NeXus file interface requires compiled libraries to read the
11 underlying HDF_ files. Binary packages are available for some
12 platforms from the NeXus site. Details of where the nxs package
13 searches for the libraries are recorded in `nxs.napi`.
14 """
15
16 import unittest
17 import nxs.napi as napi
18
19 class test_constants(unittest.TestCase):
20 """
21 Testing constants exported by nxs.
22 """
23
24
25 def test_scalar_constants(self):
26 self.assertEqual(napi.NOSTRIP,128)
27 self.assertEqual(napi.UNLIMITED,-1)
28 self.assertEqual(napi.MAXRANK,32)
29 self.assertEqual(napi.MAXNAMELEN,64)
30 self.assertEqual(napi.MAXPATHLEN,1024)
31
32 def test_type_codes(self):
33 d_expected = {"char":4,"float32":5,"float64":6,
34 "int8":20,"uint8":21,"int16":22,"uint16":23,
35 "int32":24,"uint32":25,"int64":26,"uint64":27}
36 self.assertDictEqual(napi._nxtype_code,d_expected)
37
38 def test_open_modes(self):
39 dr = {"r":1,"rw":2,"w":3,"w4":4,"w5":5,"wx":6}
40 self.assertDictEqual(napi._nxopen_mode,dr)
41
42 def test_compression_code(self):
43 d_expected = {"none":100,"lzw":200,"rle":300,"huffman":400}
44 self.assertDictEqual(napi._compression_code,d_expected)
45
46 def test_h4skip(self):
47 l_expected = ['CDF0.0','_HDF_CHK_TBL_','Attr0.0','RIG0.0','RI0.0',
48 'RIATTR0.0N','RIATTR0.0C']
49 self.assertListEqual(napi.H4SKIP,l_expected)
50