Skip to content

Commit

Permalink
ColorSpaceTest : Remove confusing intermediate variables
Browse files Browse the repository at this point in the history
Also fix misc formatting issues.
  • Loading branch information
johnhaddon committed Jun 2, 2023
1 parent c8e469b commit 2621c49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 47 deletions.
38 changes: 14 additions & 24 deletions python/GafferImageTest/ColorSpaceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def testPassThrough( self ) :
def testContext( self ) :

scriptFileName = self.temporaryDirectory() / "script.gfr"
contextImageFile = self.temporaryDirectory() / "context.#.exr"
contextOverrideImageFile = self.temporaryDirectory() / "context_override.#.exr"
contextImageFile = self.temporaryDirectory() / "context.exr"
contextOverrideImageFile = self.temporaryDirectory() / "context_override.exr"

s = Gaffer.ScriptNode()

Expand All @@ -185,7 +185,6 @@ def testContext( self ) :
s["cs"]["inputSpace"].setValue( "linear" )
s["cs"]["outputSpace"].setValue( "context" )


s["writer"] = GafferImage.ImageWriter()
s["writer"]["fileName"].setValue( contextImageFile )
s["writer"]["in"].setInput( s["cs"]["out"] )
Expand All @@ -200,46 +199,37 @@ def testContext( self ) :
env["CDL"] = "cineon.spi1d"

subprocess.check_call(
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ),"-frames", "1" ],
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ), "-frames", "1" ],
stderr = subprocess.PIPE,
env = env,
)

i = GafferImage.ImageReader()
i["fileName"].setValue( self.imagesPath() / "checker_ocio_context.exr" )

o = GafferImage.ImageReader()
o["fileName"].setValue( contextImageFile )
expected = GafferImage.ImageReader()
expected["fileName"].setValue( self.imagesPath() / "checker_ocio_context.exr" )

expected = i["out"]
context = o["out"]
actual = GafferImage.ImageReader()
actual["fileName"].setValue( contextImageFile )

# check against expected output
self.assertImagesEqual( expected, context, ignoreMetadata = True )
self.assertImagesEqual( actual["out"], expected["out"], ignoreMetadata = True )

# override context
s["writer"]["fileName"].setValue( contextOverrideImageFile )
s["cs"]["context"].addChild( Gaffer.NameValuePlug("LUT", "cineon.spi1d", True, "LUT", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["cs"]["context"].addChild( Gaffer.NameValuePlug("CDL", "rec709.spi1d", True, "CDL", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["cs"]["context"].addChild( Gaffer.NameValuePlug( "LUT", "cineon.spi1d", True, "LUT", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["cs"]["context"].addChild( Gaffer.NameValuePlug( "CDL", "rec709.spi1d", True, "CDL", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s.save()

subprocess.check_call(
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ),"-frames", "1" ],
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ), "-frames", "1" ],
stderr = subprocess.PIPE,
env = env
)

i = GafferImage.ImageReader()
i["fileName"].setValue( self.imagesPath() / "checker_ocio_context_override.exr" )

o = GafferImage.ImageReader()
o["fileName"].setValue( contextOverrideImageFile )

expected = i["out"]
context = o["out"]
expected["fileName"].setValue( self.imagesPath() / "checker_ocio_context_override.exr" )
actual["fileName"].setValue( contextOverrideImageFile )

# check override produce expected output
self.assertImagesEqual( expected, context, ignoreMetadata = True )
self.assertImagesEqual( actual["out"], expected["out"], ignoreMetadata = True )

def testSingleChannelImage( self ) :

Expand Down
37 changes: 14 additions & 23 deletions python/GafferImageTest/DisplayTransformTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def testPassThrough( self ) :
def testContext( self ) :

scriptFileName = self.temporaryDirectory() / "script.gfr"
contextImageFile = self.temporaryDirectory() / "context.#.exr"
contextOverrideImageFile = self.temporaryDirectory() / "context_override.#.exr"
contextImageFile = self.temporaryDirectory() / "context.exr"
contextOverrideImageFile = self.temporaryDirectory() / "context_override.exr"

s = Gaffer.ScriptNode()

Expand Down Expand Up @@ -205,46 +205,37 @@ def testContext( self ) :
env["CDL"] = "cineon.spi1d"

subprocess.check_call(
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ),"-frames", "1" ],
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ), "-frames", "1" ],
stderr = subprocess.PIPE,
env = env,
)

i = GafferImage.ImageReader()
i["fileName"].setValue( self.imagesPath() / "checker_ocio_context.exr" )

o = GafferImage.ImageReader()
o["fileName"].setValue( contextImageFile )
expected = GafferImage.ImageReader()
expected["fileName"].setValue( self.imagesPath() / "checker_ocio_context.exr" )

expected = i["out"]
context = o["out"]
actual = GafferImage.ImageReader()
actual["fileName"].setValue( contextImageFile )

# check against expected output
self.assertImagesEqual( expected, context, ignoreMetadata = True )
self.assertImagesEqual( actual["out"], expected["out"], ignoreMetadata = True )

# override context
s["writer"]["fileName"].setValue( contextOverrideImageFile )
s["dt"]["context"].addChild( Gaffer.NameValuePlug("LUT", IECore.StringData( "cineon.spi1d" ), True, "LUT", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["dt"]["context"].addChild( Gaffer.NameValuePlug("CDL", IECore.StringData( "rec709.spi1d" ), True, "CDL", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["dt"]["context"].addChild( Gaffer.NameValuePlug( "LUT", IECore.StringData( "cineon.spi1d" ), True, "LUT", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s["dt"]["context"].addChild( Gaffer.NameValuePlug( "CDL", IECore.StringData( "rec709.spi1d" ), True, "CDL", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
s.save()

subprocess.check_call(
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ),"-frames", "1" ],
[ str( Gaffer.executablePath() ), "execute", str( scriptFileName ), "-frames", "1" ],
stderr = subprocess.PIPE,
env = env
)

i = GafferImage.ImageReader()
i["fileName"].setValue( self.imagesPath() / "checker_ocio_context_override.exr" )

o = GafferImage.ImageReader()
o["fileName"].setValue( contextOverrideImageFile )

expected = i["out"]
context = o["out"]
expected["fileName"].setValue( self.imagesPath() / "checker_ocio_context_override.exr" )
actual["fileName"].setValue( contextOverrideImageFile )

# check override produce expected output
self.assertImagesEqual( expected, context, ignoreMetadata = True )
self.assertImagesEqual( actual["out"], expected["out"], ignoreMetadata = True )

if __name__ == "__main__":
unittest.main()

0 comments on commit 2621c49

Please sign in to comment.