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

Method testResize

test/IECore/ObjectMatrixTest.py:187–216  ·  view source on GitHub ↗
( self )

Source from the content-addressed store, hash-verified

185 self.assertEqual( repr( m ), "IECore.ObjectMatrix( [ [ IECore.IntData( 42 ), IECore.StringData( '123' ) ], [ IECore.FloatData( 0.1 ), IECore.CompoundData() ], [ None, IECore.StringVectorData( [ 'a' ] ) ] ] )" )
186
187 def testResize( self ) :
188
189 m1 = IECore.ObjectMatrix( 3, 3 )
190 for row in range( 3 ) :
191 for column in range( 3 ) :
192 m1[row, column] = IECore.IntData( row * 3 + column )
193
194 m2 = m1.copy()
195 self.assertEqual( m1, m2 )
196
197 # Enlarge m2. Its values should match their equivalent coordinate in m1.
198 m2.resize( 5, 4 )
199 self.assertNotEqual( m1, m2 )
200
201 for row in range( m2.numRows() ) :
202 for column in range( m2.numColumns() ) :
203 if row < m1.numRows() and column < m1.numColumns() :
204 self.assertEqual( m1[row, column], m2[row, column] )
205 else :
206 self.assertIsNone( m2[row, column] )
207
208 # Shrink m2 back to the same size as m1. Both should match.
209 m2.resize( 3, 3 )
210 self.assertEqual( m1, m2 )
211
212 # Shrink m2 smaller than m1, remaining values should still match their equivalent coordinate in m1.
213 m2.resize( 2, 2 )
214 for row in range( m2.numRows() ) :
215 for column in range( m2.numRows() ) :
216 self.assertEqual( m1[row, column], m2[row, column] )
217
218if __name__ == "__main__":
219 unittest.main()

Callers

nothing calls this directly

Calls 5

numRowsMethod · 0.95
numColumnsMethod · 0.95
ObjectMatrixMethod · 0.80
copyMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected