-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTest_ENDFtk_MF14_LegendreCoefficients.py
More file actions
68 lines (46 loc) · 2.37 KB
/
Test_ENDFtk_MF14_LegendreCoefficients.py
File metadata and controls
68 lines (46 loc) · 2.37 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# standard imports
import unittest
# third party imports
# local imports
from ENDFtk.MF14 import LegendreCoefficients
class Test_ENDFtk_MF14_LegendreCoefficients( unittest.TestCase ) :
"""Unit test for the LegendreCoefficients class."""
chunk = ( ' 0.000000+0 1.000000-5 0 0 3 0922814 2 \n'
' 7.392510-5 8.477139-9 1.17106-13 922814 2 \n' )
invalid = ( ' 0.000000+0 1.000000-5 0 0 2 0922814 2 \n'
' 7.392510-5 8.477139-9 1.17106-13 922814 2 \n' )
def test_component( self ) :
def verify_chunk( self, chunk ) :
# verify content
self.assertAlmostEqual( 1e-5, chunk.E )
self.assertAlmostEqual( 1e-5, chunk.incident_energy )
self.assertEqual( 3, chunk.NL )
self.assertEqual( 3, chunk.legendre_order )
self.assertEqual( 3, len( chunk.A ) )
self.assertEqual( 3, len( chunk.coefficients ) )
self.assertAlmostEqual( 7.392510e-5 , chunk.A[0] )
self.assertAlmostEqual( 8.477139e-9, chunk.A[1] )
self.assertAlmostEqual( 1.17106e-13, chunk.A[2] )
self.assertAlmostEqual( 7.392510e-5 , chunk.coefficients[0] )
self.assertAlmostEqual( 8.477139e-9, chunk.coefficients[1] )
self.assertAlmostEqual( 1.17106e-13, chunk.coefficients[2] )
self.assertEqual( 2, chunk.NC )
# verify string
self.assertEqual( self.chunk, chunk.to_string( 9228, 14, 2 ) )
# the data is given explicitly
chunk = LegendreCoefficients( energy = 1e-5,
coefficients = [ 7.392510e-5, 8.477139e-9,
1.17106e-13 ] )
verify_chunk( self, chunk )
# the data is read from a string
chunk = LegendreCoefficients.from_string( self.chunk, 9228, 14, 2 )
verify_chunk( self, chunk )
# the data is copied
copy = LegendreCoefficients( chunk )
verify_chunk( self, copy )
def test_failures( self ) :
print( '\n' )
with self.assertRaises( Exception ) :
chunk = LegendreCoefficients.from_string( self.invalid, 9228, 14, 2 )
if __name__ == '__main__' :
unittest.main()