( self )
| 1046 | self.assertAlmostEqual( t[0], 5 + 0.5 * i, 9 ) |
| 1047 | |
| 1048 | def testHashes( self ): |
| 1049 | |
| 1050 | m = IECoreScene.SceneCache( os.path.join( "test", "IECore", "data", "sccFiles", "animatedSpheres.scc" ), IECore.IndexedIO.OpenMode.Read ) |
| 1051 | |
| 1052 | def collectHashes( scene, hashType, time, hashResults ) : |
| 1053 | counter = 1 |
| 1054 | h = scene.hash( hashType, time ).toString() |
| 1055 | hashResults.add( h ) |
| 1056 | for n in scene.childNames() : |
| 1057 | counter += collectHashes( scene.child(n), hashType, time, hashResults ) |
| 1058 | return counter |
| 1059 | |
| 1060 | hashTypes = IECoreScene.SceneInterface.HashType.values.values() |
| 1061 | |
| 1062 | def checkHash( hashType, scene, currTime, duplicates = 0 ): |
| 1063 | hh = set() |
| 1064 | cc = collectHashes( scene, hashType, currTime, hh ) |
| 1065 | self.assertEqual( cc - duplicates, len(hh) ) |
| 1066 | return ( cc, hh ) |
| 1067 | |
| 1068 | t0 = checkHash( IECoreScene.SceneInterface.HashType.TransformHash, m, 0 ) |
| 1069 | t1 = checkHash( IECoreScene.SceneInterface.HashType.TransformHash, m, 1 ) |
| 1070 | self.assertEqual( t0[0]+t1[0]-1, len(t0[1].union(t1[1])) ) # all transforms should be animated except the root |
| 1071 | |
| 1072 | t05 = checkHash( IECoreScene.SceneInterface.HashType.TransformHash, m, 0.5 ) |
| 1073 | self.assertEqual( t0[0]+t05[0]+t1[0]-2, len(t0[1].union(t05[1].union(t1[1]))) ) # all transforms should be animated except the root |
| 1074 | |
| 1075 | tn1 = checkHash( IECoreScene.SceneInterface.HashType.TransformHash, m, -1 ) |
| 1076 | self.assertEqual( t0[0], len(t0[1].union(tn1[1])) ) # time 0 should match time -1's hashes |
| 1077 | |
| 1078 | duplicatedAttributes = 2 |
| 1079 | t0 = checkHash( IECoreScene.SceneInterface.HashType.AttributesHash, m, 0, duplicatedAttributes ) |
| 1080 | t1 = checkHash( IECoreScene.SceneInterface.HashType.AttributesHash, m, 1, duplicatedAttributes ) |
| 1081 | self.assertEqual( t0[0] - duplicatedAttributes, len(t0[1].union(t1[1])) ) # attributes are not animated in the example scene |
| 1082 | |
| 1083 | t0 = checkHash( IECoreScene.SceneInterface.HashType.BoundHash, m, 0 ) |
| 1084 | t1 = checkHash( IECoreScene.SceneInterface.HashType.BoundHash, m, 1 ) |
| 1085 | self.assertEqual( t0[0]+t1[0]-1, len(t0[1].union(t1[1])) ) # only object at /A/a is constant in time and not vary it's bounds everything else differs |
| 1086 | |
| 1087 | noObjects = 2 |
| 1088 | t0 = checkHash( IECoreScene.SceneInterface.HashType.ObjectHash, m, 0, noObjects ) |
| 1089 | t1 = checkHash( IECoreScene.SceneInterface.HashType.ObjectHash, m, 1, noObjects ) |
| 1090 | self.assertEqual( t0[0] - noObjects + 1, len(t0[1].union(t1[1])) ) # only object at /B/b vary in time everything else should match |
| 1091 | |
| 1092 | t0 = checkHash( IECoreScene.SceneInterface.HashType.ChildNamesHash, m, 0 ) |
| 1093 | t1 = checkHash( IECoreScene.SceneInterface.HashType.ChildNamesHash, m, 1 ) |
| 1094 | self.assertEqual( t0[0], len(t0[1].union(t1[1])) ) # child names does not change over time |
| 1095 | |
| 1096 | t0 = checkHash( IECoreScene.SceneInterface.HashType.HierarchyHash, m, 0 ) |
| 1097 | t1 = checkHash( IECoreScene.SceneInterface.HashType.HierarchyHash, m, 1 ) |
| 1098 | self.assertEqual( t0[0] + t1[0], len(t0[1].union(t1[1])) ) # all locations differ |
| 1099 | |
| 1100 | def testHashStability( self ) : |
| 1101 |
nothing calls this directly
no test coverage detected