Ejemplo n.º 1
0
 def test_interface(self):
     bake = OCIO.Baker()
     bakee = bake.createEditableCopy()
     cfg = OCIO.Config().CreateFromStream(self.SIMPLE_PROFILE)
     self.assertEqual(2, cfg.getNumColorSpaces())
     bakee.setConfig(cfg)
     cfg2 = bakee.getConfig()
     self.assertEqual(2, cfg2.getNumColorSpaces())
     bakee.setFormat("cinespace")
     self.assertEqual("cinespace", bakee.getFormat())
     bakee.setType("3D")
     self.assertEqual("3D", bakee.getType())
     bakee.setMetadata("this is some metadata!")
     self.assertEqual("this is some metadata!", bakee.getMetadata())
     bakee.setInputSpace("lnh")
     self.assertEqual("lnh", bakee.getInputSpace())
     bakee.setLooks("foo, +bar")
     self.assertEqual("foo, +bar", bakee.getLooks())
     bakee.setLooks("")
     bakee.setTargetSpace("test")
     self.assertEqual("test", bakee.getTargetSpace())
     bakee.setShaperSize(4)
     self.assertEqual(4, bakee.getShaperSize())
     bakee.setCubeSize(2)
     self.assertEqual(2, bakee.getCubeSize())
     output = bakee.bake()
     if self.useSSE == True:
         self.assertEqual(self.EXPECTED_LUT_SSE, output)
     else:
         self.assertEqual(self.EXPECTED_LUT_NONSSE, output)
     self.assertEqual(8, bakee.getNumFormats())
     self.assertEqual("cinespace", bakee.getFormatNameByIndex(2))
     self.assertEqual("3dl", bakee.getFormatExtensionByIndex(1))
Ejemplo n.º 2
0
    def test_copy(self):
        """
        Test the deepcopy() method.
        """
        cfg = OCIO.Config().CreateFromStream(self.SIMPLE_PROFILE)

        bake = OCIO.Baker()
        bake.setConfig(cfg)
        bake.setFormat("cinespace")
        bake.setInputSpace("lnh")
        bake.setLooks("foo, +bar")
        bake.setTargetSpace("test")
        bake.setShaperSize(4)
        bake.setCubeSize(2)

        other = copy.deepcopy(bake)
        self.assertFalse(other is bake)

        self.assertEqual(other.getConfig(), bake.getConfig())
        self.assertEqual(other.getFormat(), bake.getFormat())
        self.assertEqual(other.getInputSpace(), bake.getInputSpace())
        self.assertEqual(other.getLooks(), bake.getLooks())
        self.assertEqual(other.getTargetSpace(), bake.getTargetSpace())
        self.assertEqual(other.getShaperSize(), bake.getShaperSize())
        self.assertEqual(other.getCubeSize(), bake.getCubeSize())
Ejemplo n.º 3
0
    def test_interface(self):
        """
        Test similar to C++ CPU test.
        """
        bake = OCIO.Baker()
        cfg = OCIO.Config().CreateFromStream(self.SIMPLE_PROFILE)
        cs = cfg.getColorSpaces()
        self.assertEqual(len(cs), 2)
        bake.setConfig(cfg)
        cfg2 = bake.getConfig()
        cs2 = cfg2.getColorSpaces()
        self.assertEqual(len(cs2), 2)

        bake.setFormat("cinespace")
        self.assertEqual("cinespace", bake.getFormat())
        bake.setInputSpace("lnh")
        self.assertEqual("lnh", bake.getInputSpace())
        bake.setLooks("foo, +bar")
        self.assertEqual("foo, +bar", bake.getLooks())
        bake.setLooks("")
        bake.setTargetSpace("test")
        self.assertEqual("test", bake.getTargetSpace())
        bake.setShaperSize(4)
        self.assertEqual(4, bake.getShaperSize())
        bake.setCubeSize(2)
        self.assertEqual(2, bake.getCubeSize())
        output = bake.bake()
        lines = output.splitlines()
        expected_lines = self.EXPECTED_LUT.splitlines()
        self.assertEqual(len(lines), len(expected_lines))
        # Text compare for the first lines.
        for i in range(6):
            self.assertEqual(lines[i], expected_lines[i])
        # Compare values after (results might be slightly different on some plaforms).
        for i in range(6, len(lines)):
            # Skip blank lines.
            if lines[i] == '':
                continue
            # Line 16 is the cube size.
            if i == 16:
                self.assertEqual(lines[i], expected_lines[i])
                continue
            lf = lines[i].split(' ')
            elf = expected_lines[i].split(' ')
            for j in range(len(lf)):
                self.assertAlmostEqual(float(lf[j]),
                                       float(elf[j]),
                                       delta=0.00001)
        fmts = bake.getFormats()
        self.assertEqual(len(fmts), 10)
        self.assertEqual("cinespace", fmts[4][0])
        self.assertEqual("3dl", fmts[1][1])