MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testInfinity

Method testInfinity

test/IECore/ReprTest.py:64–83  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

62 self.assertEqual( v, eval( IECore.repr( v ) ) )
63
64 def testInfinity( self ) :
65
66 for v in [
67 # Python raises "OverflowError : bad numeric conversion : positive overflow"
68 # when passing `float( "inf" )` to `V2f``
69 imath.V2d( float( "inf" ), float( "inf" ) ),
70 imath.V3f( float( "inf" ), float( "inf" ), float( "inf" ) ),
71 imath.V3d( float( "inf" ), float( "inf" ), float( "inf" ) ),
72 imath.Color3f( float( "inf" ), float( "inf" ), float( "inf" ) ),
73 imath.Color4f( float( "inf" ), float( "inf" ), float( "inf" ), float( "inf" ) ),
74 ] :
75 with self.subTest( v = v ) :
76 self.assertTrue( type( v ) is type( eval( IECore.repr( v ) ) ) )
77 self.assertEqual( v, eval( IECore.repr( v ) ) )
78
79 self.assertTrue( type( -v ) is type( eval( IECore.repr( -v ) ) ) )
80 self.assertEqual( -v, eval( IECore.repr( -v ) ) )
81
82 self.assertEqual( str( v ), "{}({})".format( type( v ).__name__, ", ".join( ["inf"] * v.dimensions() ) ) )
83 self.assertEqual( str( -v ), "{}({})".format( type( v ).__name__, ", ".join( ["-inf"] * v.dimensions() ) ) )
84
85
86if __name__ == "__main__":

Callers

nothing calls this directly

Calls 5

typeFunction · 0.85
reprMethod · 0.80
joinMethod · 0.80
strFunction · 0.50
dimensionsMethod · 0.45

Tested by

no test coverage detected