def test_contructor(self): """ Test GradingPrimaryTransform constructor without and with keywords. """ gpt = OCIO.GradingPrimaryTransform() self.assertEqual(gpt.getStyle(), OCIO.GRADING_LOG) assertEqualPrimary(self, gpt.getValue(), self.valsDefaultLog) self.assertEqual(gpt.isDynamic(), False) self.assertEqual(gpt.getDirection(), OCIO.TRANSFORM_DIR_FORWARD) gpt = OCIO.GradingPrimaryTransform(OCIO.GRADING_LIN) self.assertEqual(gpt.getStyle(), OCIO.GRADING_LIN) assertEqualPrimary(self, gpt.getValue(), self.valsDefault) self.assertEqual(gpt.isDynamic(), False) self.assertEqual(gpt.getDirection(), OCIO.TRANSFORM_DIR_FORWARD) vals = OCIO.GradingPrimary(OCIO.GRADING_LOG) vals.clampBlack = 0.1 gpt = OCIO.GradingPrimaryTransform(style=OCIO.GRADING_VIDEO, values=vals, dynamic=True, dir=OCIO.TRANSFORM_DIR_INVERSE) self.assertEqual(gpt.getStyle(), OCIO.GRADING_VIDEO) self.assertEqual(gpt.isDynamic(), True) self.assertEqual(gpt.getDirection(), OCIO.TRANSFORM_DIR_INVERSE) assertEqualPrimary(self, gpt.getValue(), vals) gpt = OCIO.GradingPrimaryTransform(style=OCIO.GRADING_LOG, dynamic=False, dir=OCIO.TRANSFORM_DIR_INVERSE) self.assertEqual(gpt.getStyle(), OCIO.GRADING_LOG) self.assertEqual(gpt.isDynamic(), False) self.assertEqual(gpt.getDirection(), OCIO.TRANSFORM_DIR_INVERSE) assertEqualPrimary(self, gpt.getValue(), self.valsDefaultLog) # White has to be bigger than white. vals.clampBlack = 0.9 vals.clampWhite = 0.1 with self.assertRaises(OCIO.Exception): OCIO.GradingPrimaryTransform(values=vals) # Gamma has to be above lower bound. vals.clampBlack = 0.1 vals.clampWhite = 0.9 vals.gamma.blue = 0.001 with self.assertRaises(OCIO.Exception): OCIO.GradingPrimaryTransform(values=vals)
def test_values(self): """ Test setValue() and getValue(). """ gpt = OCIO.GradingPrimaryTransform(OCIO.GRADING_LOG) vals = OCIO.GradingPrimary(OCIO.GRADING_LOG) vals.contrast = OCIO.GradingRGBM(1.1, 0.9, 1.2, 1) vals.clampBlack = 0.1 gpt.setValue(vals) assertEqualPrimary(self, gpt.getValue(), vals) vals.offset = OCIO.GradingRGBM(0, 0.1, -0.1, 0) with self.assertRaises(AssertionError): assertEqualPrimary(self, gpt.getValue(), vals) gpt.setValue(vals) assertEqualPrimary(self, gpt.getValue(), vals)
def test_primary(self): """ Test the GradingPrimary struct. """ rgbm0 = OCIO.GradingRGBM(0, 0, 0, 0) rgbm1 = OCIO.GradingRGBM(1, 1, 1, 1) # Constructor. primaryLog = OCIO.GradingPrimary(OCIO.GRADING_LOG) assertEqualRGBM(self, rgbm0, primaryLog.brightness) assertEqualRGBM(self, rgbm1, primaryLog.contrast) assertEqualRGBM(self, rgbm1, primaryLog.gamma) assertEqualRGBM(self, rgbm0, primaryLog.offset) assertEqualRGBM(self, rgbm0, primaryLog.exposure) assertEqualRGBM(self, rgbm0, primaryLog.lift) assertEqualRGBM(self, rgbm1, primaryLog.gain) self.assertEqual(-0.2, primaryLog.pivot) self.assertEqual(1, primaryLog.saturation) # Check that the default values do not clamp. self.assertEqual(primaryLog.NoClampWhite, primaryLog.clampWhite) self.assertEqual(primaryLog.NoClampBlack, primaryLog.clampBlack) self.assertEqual(1, primaryLog.pivotWhite) self.assertEqual(0, primaryLog.pivotBlack) primaryLin = OCIO.GradingPrimary(OCIO.GRADING_LIN) with self.assertRaises(AssertionError): assertEqualPrimary(self, primaryLog, primaryLin) primaryLog.pivot = 0.18 assertEqualPrimary(self, primaryLog, primaryLin) primaryVideo = OCIO.GradingPrimary(OCIO.GRADING_VIDEO) assertEqualPrimary(self, primaryLog, primaryVideo) with self.assertRaises(TypeError): OCIO.GradingPrimary() with self.assertRaises(AttributeError): OCIO.GradingPrimary(OCIO.TRANSFOR_DIRECTION_FORWARD) with self.assertRaises(TypeError): OCIO.GradingPrimary(0) newGamma = OCIO.GradingRGBM(1.1, 1.2, 1.3, 1) primaryLog.gamma = newGamma assertEqualRGBM(self, newGamma, primaryLog.gamma)