Skip to content

Commit

Permalink
test/IECoreGL : Relax precisions for image comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanimanishi committed Nov 6, 2024
1 parent 1b9f885 commit e28e158
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 41 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Build

- CI :
- IECoreHoudini tests updated to pass on newer environments.
- IECoreGL tests updated with relaxed precisions for image comparisons.

10.5.10.0 (relative to 10.5.9.5)
=========
Expand Down
16 changes: 8 additions & 8 deletions test/IECoreGL/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def testPositioning( self ) :
i = IECore.Reader.create( os.path.join( os.path.dirname( __file__ ), "output", "testCamera.tif" ) ).read()
dimensions = i.dataWindow.size() + imath.V2i( 1 )
midpoint = dimensions.x * dimensions.y//2 + dimensions.x//2
self.assertEqual( i["G"][midpoint], 0 )
self.assertAlmostEqual( i["G"][midpoint], 0, 6 )

# render a plane at z = 0 with the camera moved back a touch to see it
r = IECoreGL.Renderer()
Expand All @@ -87,7 +87,7 @@ def testPositioning( self ) :
i = IECore.Reader.create( os.path.join( os.path.dirname( __file__ ), "output", "testCamera.tif" ) ).read()
dimensions = i.dataWindow.size() + imath.V2i( 1 )
midpoint = dimensions.x * dimensions.y//2 + dimensions.x//2
self.assertEqual( i["A"][midpoint], 1 )
self.assertAlmostEqual( i["A"][midpoint], 1, 6 )

def testXYOrientation( self ) :

Expand All @@ -113,15 +113,15 @@ def testXYOrientation( self ) :
i = IECore.Reader.create( os.path.join( os.path.dirname( __file__ ), "output", "testCamera.tif" ) ).read()
dimensions = i.dataWindow.size() + imath.V2i( 1 )
index = dimensions.x * dimensions.y//2 + dimensions.x - 1
self.assertEqual( i["A"][index], 1 )
self.assertAlmostEqual( i["A"][index], 1, 6 )
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertEqual( i["G"][index], 0 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 0, 6 )
index = dimensions.x//2
self.assertEqual( i["A"][index], 1 )
self.assertEqual( i["R"][index], 0 )
self.assertAlmostEqual( i["A"][index], 1, 6 )
self.assertAlmostEqual( i["R"][index], 0, 6 )
self.assertAlmostEqual( i["G"][index], 1, 6 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

def setUp( self ) :

Expand Down
18 changes: 9 additions & 9 deletions test/IECoreGL/ImmediateRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ def test( self ) :
i = IECore.Reader.create( outputFileName ).read()
dimensions = i.dataWindow.size() + imath.V2i( 1 )
index = int(dimensions.x * 0.5)
self.assertEqual( i["A"][index], 1 )
self.assertAlmostEqual( i["A"][index], 1, 6 )
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertAlmostEqual( i["G"][index], 1, 6 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["B"][index], 0, 6 )
index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5)
self.assertEqual( i["A"][index], 1 )
self.assertEqual( i["R"][index], 0 )
self.assertEqual( i["G"][index], 0 )
self.assertAlmostEqual( i["A"][index], 1, 6 )
self.assertAlmostEqual( i["R"][index], 0, 6 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 1, 6 )
index = 0
self.assertEqual( i["A"][index], 0 )
self.assertEqual( i["R"][index], 0 )
self.assertEqual( i["G"][index], 0 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["A"][index], 0, 6 )
self.assertAlmostEqual( i["R"][index], 0, 6 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

def setUp( self ) :

Expand Down
24 changes: 12 additions & 12 deletions test/IECoreGL/MeshPrimitiveTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,22 @@ def testUniformCs( self ) :
dimensions = image.dataWindow.size() + imath.V2i( 1 )
index = dimensions.x * int(dimensions.y * 0.75) + int(dimensions.x * 0.25)
self.assertAlmostEqual( image["R"][index], 1, 6 )
self.assertEqual( image["G"][index], 0 )
self.assertEqual( image["B"][index], 0 )
self.assertAlmostEqual( image["G"][index], 0, 6 )
self.assertAlmostEqual( image["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.75) + int(dimensions.x * 0.75)
self.assertEqual( image["R"][index], 0 )
self.assertAlmostEqual( image["R"][index], 0, 6 )
self.assertAlmostEqual( image["G"][index], 1, 6 )
self.assertEqual( image["B"][index], 0 )
self.assertAlmostEqual( image["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.25) + int(dimensions.x * 0.75)
self.assertAlmostEqual( image["R"][index], 1, 6 )
self.assertAlmostEqual( image["G"][index], 1, 6 )
self.assertAlmostEqual( image["B"][index], 1, 6 )

index = dimensions.x * int(dimensions.y * 0.25) + int(dimensions.x * 0.25)
self.assertEqual( image["R"][index], 0 )
self.assertEqual( image["G"][index], 0 )
self.assertAlmostEqual( image["R"][index], 0, 6 )
self.assertAlmostEqual( image["G"][index], 0, 6 )
self.assertAlmostEqual( image["B"][index], 1, 6 )

def testBound( self ) :
Expand All @@ -192,10 +192,10 @@ def testFaceNormals( self ) :
#include "IECoreGL/FragmentShader.h"
IECOREGL_FRAGMENTSHADER_IN vec3 fragmentN;
void main()
{
gl_FragColor = vec4( fragmentN, 1.0 );
}
void main()
{
gl_FragColor = vec4( fragmentN, 1.0 );
}
"""

r = IECoreGL.Renderer()
Expand Down Expand Up @@ -224,8 +224,8 @@ def testFaceNormals( self ) :
image = IECore.Reader.create( self.outputFileName ).read()
dimensions = image.dataWindow.size() + imath.V2i( 1 )
index = dimensions.x * dimensions.y//2 + dimensions.x//2
self.assertEqual( image["R"][index], 0 )
self.assertEqual( image["G"][index], 0 )
self.assertAlmostEqual( image["R"][index], 0, 6 )
self.assertAlmostEqual( image["G"][index], 0, 6 )
self.assertAlmostEqual( image["B"][index], 1, 6 )

def testIndexedUV( self ) :
Expand Down
22 changes: 11 additions & 11 deletions test/IECoreGL/Renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,17 @@ def testStackBug( self ) :
index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5)
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertAlmostEqual( i["G"][index], 1, 6 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.5)
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertEqual( i["G"][index], 0 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 1) - 1
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertEqual( i["G"][index], 0 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

def testPrimVars( self ) :

Expand Down Expand Up @@ -345,18 +345,18 @@ def testPrimVars( self ) :
i = IECore.Reader.create( os.path.join( os.path.dirname( __file__ ), "output", "testPrimVars.tif" ) ).read()
dimensions = i.dataWindow.size() + imath.V2i( 1 )
index = dimensions.x * int(dimensions.y * 0.5)
self.assertEqual( i["R"][index], 0 )
self.assertAlmostEqual( i["R"][index], 0, 6 )
self.assertAlmostEqual( i["G"][index], 1, 6 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 0.5)
self.assertAlmostEqual( i["R"][index], 1, 6 )
self.assertEqual( i["G"][index], 0 )
self.assertEqual( i["B"][index], 0 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 0, 6 )

index = dimensions.x * int(dimensions.y * 0.5) + int(dimensions.x * 1) - 1
self.assertEqual( i["R"][index], 0 )
self.assertEqual( i["G"][index], 0 )
self.assertAlmostEqual( i["R"][index], 0, 6 )
self.assertAlmostEqual( i["G"][index], 0, 6 )
self.assertAlmostEqual( i["B"][index], 1, 6 )

## \todo Make this assert something
Expand Down
3 changes: 2 additions & 1 deletion test/IECoreGL/ShadingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,10 +825,11 @@ def testVertexCsDoesntAffectWireframe( self ) :
# wireframe is green, and vertex Cs is black,
# so there should be no contribution from
# wireframe or solid shading in the red channel.
self.assertEqual( sum( image["R"] ), 0 )
self.assertAlmostEqual( sum( image["R"] ), 0, 4 )
# black vertex colour should have no effect on
# green wireframe, so we should have some wireframe
# contribution in the green channel.
self.assertNotAlmostEqual( sum( image["G"] ), 0, 4 )
self.assertTrue( sum( image["G"] ) > 0 )

def testUniformFloatArrayParameters( self ) :
Expand Down

0 comments on commit e28e158

Please sign in to comment.