| 67 | self.assertEqual( s, ss ) |
| 68 | |
| 69 | def testEvaluator( self ) : |
| 70 | |
| 71 | s = IECore.Rampff( ( ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ) ), IECore.RampInterpolation.Linear ) |
| 72 | self.assertEqual( |
| 73 | s.evaluator(), |
| 74 | IECore.Splineff( IECore.CubicBasisf.linear(), ( ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ) ) ) |
| 75 | ) |
| 76 | |
| 77 | s = IECore.Rampff( ( ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ) ), IECore.RampInterpolation.CatmullRom ) |
| 78 | self.assertEqual( |
| 79 | s.evaluator(), |
| 80 | IECore.Splineff( IECore.CubicBasisf.catmullRom(), |
| 81 | ( ( 0, 1 ), ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ), ( 3, 3 ) ) |
| 82 | ) |
| 83 | ) |
| 84 | |
| 85 | s = IECore.RampfColor3f( |
| 86 | ( ( 0, imath.Color3f(1) ), ( 1, imath.Color3f(2) ), ( 2, imath.Color3f(2) ), ( 3, imath.Color3f(3) ) ), |
| 87 | IECore.RampInterpolation.Constant |
| 88 | ) |
| 89 | self.assertEqual( |
| 90 | s.evaluator(), |
| 91 | IECore.SplinefColor3f( IECore.CubicBasisf.constant(), |
| 92 | ( ( 0, imath.Color3f(1) ), ( 1, imath.Color3f(2) ), ( 2, imath.Color3f(2) ), ( 3, imath.Color3f(3) ) ) |
| 93 | ) |
| 94 | ) |
| 95 | |
| 96 | s = IECore.Rampff( ( ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ) ), IECore.RampInterpolation.BSpline ) |
| 97 | self.assertEqual( |
| 98 | s.evaluator(), |
| 99 | IECore.Splineff( IECore.CubicBasisf.bSpline(), |
| 100 | ( ( 0, 1 ), ( 0, 1 ), ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ), ( 3, 3 ), ( 3, 3 ) ) |
| 101 | ) |
| 102 | ) |
| 103 | |
| 104 | s = IECore.Rampff( ( ( 0, 1 ), ( 1, 2 ), ( 2, 2 ), ( 3, 3 ) ), IECore.RampInterpolation.MonotoneCubic ) |
| 105 | |
| 106 | # This ought to be an assertAlmostEqual, but it's quicker to just hardcode the value of 5/3 that |
| 107 | # doesn't work out exactly right |
| 108 | self.assertEqual( |
| 109 | s.evaluator(), |
| 110 | IECore.Splineff( IECore.CubicBasisf.bezier(), ( |
| 111 | ( 0, 1), ( 1/3, 1), ( 2/3, 2 ), |
| 112 | ( 1, 2 ), ( 4/3, 2 ), ( 1.6666667461395264, 2 ), |
| 113 | ( 2, 2 ), ( 7/3, 2 ), ( 8/3, 3 ), |
| 114 | ( 3, 3 ) |
| 115 | ) ) |
| 116 | ) |
| 117 | |
| 118 | if __name__ == "__main__": |
| 119 | unittest.main() |