Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whaeck committed Jun 12, 2024
1 parent c3109d0 commit dc7fbef
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions python/test/math/Test_scion_math_InterpolationTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,50 @@ def verify_chunk4( self, chunk ) :
with self.assertRaises( Exception ) : result = 2. - chunk
with self.assertRaises( Exception ) : result = 2. * chunk

def verify_chunk5( self, chunk ) :

# verify content
self.assertEqual( 5, len( chunk.x ) )
self.assertEqual( 5, len( chunk.y ) )
self.assertEqual( 2, len( chunk.boundaries ) )
self.assertEqual( 2, len( chunk.interpolants ) )
self.assertAlmostEqual( 1., chunk.x[0] )
self.assertAlmostEqual( 2., chunk.x[1] )
self.assertAlmostEqual( 2., chunk.x[2] )
self.assertAlmostEqual( 3., chunk.x[3] )
self.assertAlmostEqual( 4., chunk.x[4] )
self.assertAlmostEqual( 4., chunk.y[0] )
self.assertAlmostEqual( 3., chunk.y[1] )
self.assertAlmostEqual( 4., chunk.y[2] )
self.assertAlmostEqual( 3., chunk.y[3] )
self.assertAlmostEqual( 2., chunk.y[4] )
self.assertEqual( 1, chunk.boundaries[0] ) # <-- this is changed from 2 to 1
self.assertEqual( 4, chunk.boundaries[1] )
self.assertEqual( InterpolationType.LinearLinear, chunk.interpolants[0] )
self.assertEqual( InterpolationType.LinearLog, chunk.interpolants[1] )
self.assertEqual( False, chunk.is_linearised )

def verify_chunk6( self, chunk ) :

# verify content
self.assertEqual( 4, len( chunk.x ) )
self.assertEqual( 4, len( chunk.y ) )
self.assertEqual( 2, len( chunk.boundaries ) )
self.assertEqual( 2, len( chunk.interpolants ) )
self.assertAlmostEqual( 1., chunk.x[0] )
self.assertAlmostEqual( 2., chunk.x[1] )
self.assertAlmostEqual( 3., chunk.x[2] )
self.assertAlmostEqual( 4., chunk.x[3] ) # <-- last point removed
self.assertAlmostEqual( 4., chunk.y[0] )
self.assertAlmostEqual( 3., chunk.y[1] )
self.assertAlmostEqual( 2., chunk.y[2] )
self.assertAlmostEqual( 1., chunk.y[3] ) # <-- last point removed
self.assertEqual( 1, chunk.boundaries[0] )
self.assertEqual( 3, chunk.boundaries[1] ) # <-- boundary value reset
self.assertEqual( InterpolationType.LinearLinear, chunk.interpolants[0] )
self.assertEqual( InterpolationType.LinearLog, chunk.interpolants[1] )
self.assertEqual( False, chunk.is_linearised )

# the data is given explicitly for data without boundaries
chunk = InterpolationTable( x = [ 1., 2., 3., 4. ],
y = [ 4., 3., 2., 1. ],
Expand Down Expand Up @@ -1491,6 +1535,24 @@ def verify_chunk4( self, chunk ) :

verify_chunk4( self, chunk )

# the data is given explicitly with boundaries that point to the second x value in the jump
chunk = InterpolationTable( x = [ 1., 2., 2., 3., 4. ],
y = [ 4., 3., 4., 3., 2. ],
boundaries = [ 2, 4 ], # <-- pointing to end of the jump
interpolants = [ InterpolationType.LinearLinear,
InterpolationType.LinearLog ] )

verify_chunk5( self, chunk )

# the data is given explicitly with a jump at the end that goes to zero
chunk = InterpolationTable( x = [ 1., 2., 3., 4., 4. ], # <-- jump at end
y = [ 4., 3., 2., 1., 0. ], # <-- last value is zero
boundaries = [ 1, 4 ], # <-- pointing to end
interpolants = [ InterpolationType.LinearLinear,
InterpolationType.LinearLog ] )

verify_chunk6( self, chunk )

def test_failures( self ) :

print( '\n' )
Expand Down

0 comments on commit dc7fbef

Please sign in to comment.