OpenColorIO icon indicating copy to clipboard operation
OpenColorIO copied to clipboard

[python][feature-request] `GradingRGBM` : fail to assertEqual 2 similar instances

Open MrLixm opened this issue 3 years ago • 1 comments

Hello,

When using ocio.GradingRGBM(), creating two instances with similar values will result in two instances that can not be matched equally like instance1==instance2.

This can bee seen in the following snippet where both tests will fail :

import unittest

import PyOpenColorIO as ocio


class OcioGradingRGBM(unittest.TestCase):
    def test_equal1(self):

        grgbm1 = ocio.GradingRGBM()
        grgbm1.master = 0.5

        grgbm2 = ocio.GradingRGBM()
        grgbm2.master = 0.5

        self.assertEqual(grgbm1, grgbm2)

    def test_equal2(self):

        grgbm1 = ocio.GradingRGBM(0.1, 0, 0, 0.5)
        grgbm2 = ocio.GradingRGBM(0.1, 0, 0, 0.5)

        self.assertEqual(grgbm1, grgbm2)


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

CONTEXT: Windows10, OCIO 2.1.0

Cheers. Liam.

MrLixm avatar May 08 '22 17:05 MrLixm

That's a good point @MrLixm, I think the bindings are currently lacking in terms of equality check for types. The only one I see explicitly defining this is ColorSpaceSet at this time. It would be nice to add support for other types where this would make sense.

This can apparently be done by adding an eq method to the exposed object or using the shortcut syntax.

Probably a good candidate for next release.

remia avatar May 12 '22 20:05 remia