Skip to content

Commit d49d7a5

Browse files
authored
Merge pull request #1374 from ImageEngine/tmpRB10.4to10.5
Merge RB-10.4 to RB-10.5
2 parents bf1a249 + ca7f808 commit d49d7a5

File tree

5 files changed

+130
-32
lines changed

5 files changed

+130
-32
lines changed

Changes

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
10.5.0.0 (relative to 10.4.10.0)
1+
10.5.0.0 (relative to 10.4.10.1)
22
========
33

44
Features
@@ -40,6 +40,15 @@ Breaking Changes
4040
- Changed function signature.
4141
- Bug fixes mean subtle changes to the resulting points.
4242

43+
10.4.10.1 (relative to 10.4.10.0)
44+
========
45+
46+
Fixes
47+
-----
48+
49+
- FrameRange : Prevented creation of FrameRanges with negative steps
50+
- IECore.dataTypeFromElement : Fixed support for list to Vector conversions
51+
4352
10.4.10.0 (relative to 10.4.9.1)
4453
========
4554

python/IECore/DataTraits.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ def isSequenceDataType(obj):
146146
IECore.M44fData: (imath.M44f, True),
147147
IECore.M44dData: (imath.M44d, True),
148148

149-
IECore.BoolVectorData: ( list, False, bool),
149+
IECore.BoolVectorData: ( list, True, bool),
150150
IECore.CharVectorData: (list, False, str),
151151
IECore.UCharVectorData: (list, False, int),
152-
IECore.IntVectorData: (list, False, int),
152+
IECore.IntVectorData: (list, True, int),
153153
IECore.UIntVectorData: (list, False, int),
154154
IECore.HalfVectorData: (list, False, float),
155155
IECore.FloatVectorData: (list, False, float),
156-
IECore.DoubleVectorData: (list, False, float),
157-
IECore.StringVectorData: (list, False, str),
158-
IECore.InternedStringVectorData: (list, False, IECore.InternedString),
156+
IECore.DoubleVectorData: (list, True, float),
157+
IECore.StringVectorData: (list, True, str),
158+
IECore.InternedStringVectorData: (list, True, IECore.InternedString),
159159
IECore.ShortVectorData: (list, False, int),
160160
IECore.UShortVectorData: (list, False, int),
161161
IECore.Int64VectorData: (list, False, int),
@@ -166,27 +166,27 @@ def isSequenceDataType(obj):
166166
IECore.V3fVectorDataBase: (list, False, imath.V3f),
167167
IECore.V3dVectorDataBase: (list, False, imath.V3d),
168168
IECore.V3iVectorDataBase: (list, False, imath.V3i),
169-
IECore.V2fVectorData: (list, False, imath.V2f),
170-
IECore.V2dVectorData: (list, False, imath.V2d),
171-
IECore.V2iVectorData: (list, False, imath.V2i),
172-
IECore.V3fVectorData: (list, False, imath.V3f),
173-
IECore.V3dVectorData: (list, False, imath.V3d),
174-
IECore.V3iVectorData: (list, False, imath.V3i),
175-
IECore.QuatfVectorData: (list, False, imath.Quatf),
176-
IECore.QuatdVectorData: (list, False, imath.Quatd),
177-
IECore.Box2iVectorData: (list, False, imath.Box2i),
178-
IECore.Box2fVectorData: (list, False, imath.Box2f),
179-
IECore.Box2dVectorData: (list, False, imath.Box2d),
180-
IECore.Box3iVectorData: (list, False, imath.Box3i),
181-
IECore.Box3fVectorData: (list, False, imath.Box3f),
182-
IECore.Box3dVectorData: (list, False, imath.Box3d),
183-
IECore.M33fVectorData: (list, False, imath.M33f),
184-
IECore.M33dVectorData: (list, False, imath.M33d),
185-
IECore.M44fVectorData: (list, False, imath.M44f),
186-
IECore.M44dVectorData: (list, False, imath.M44d),
187-
IECore.Color3fVectorData: (list, False, imath.Color3f),
169+
IECore.V2fVectorData: (list, True, imath.V2f),
170+
IECore.V2dVectorData: (list, True, imath.V2d),
171+
IECore.V2iVectorData: (list, True, imath.V2i),
172+
IECore.V3fVectorData: (list, True, imath.V3f),
173+
IECore.V3dVectorData: (list, True, imath.V3d),
174+
IECore.V3iVectorData: (list, True, imath.V3i),
175+
IECore.QuatfVectorData: (list, True, imath.Quatf),
176+
IECore.QuatdVectorData: (list, True, imath.Quatd),
177+
IECore.Box2iVectorData: (list, True, imath.Box2i),
178+
IECore.Box2fVectorData: (list, True, imath.Box2f),
179+
IECore.Box2dVectorData: (list, True, imath.Box2d),
180+
IECore.Box3iVectorData: (list, True, imath.Box3i),
181+
IECore.Box3fVectorData: (list, True, imath.Box3f),
182+
IECore.Box3dVectorData: (list, True, imath.Box3d),
183+
IECore.M33fVectorData: (list, True, imath.M33f),
184+
IECore.M33dVectorData: (list, True, imath.M33d),
185+
IECore.M44fVectorData: (list, True, imath.M44f),
186+
IECore.M44dVectorData: (list, True, imath.M44d),
187+
IECore.Color3fVectorData: (list, True, imath.Color3f),
188188
#IECore.Color3dVectorData: (list, False, IECore.Color3d),
189-
IECore.Color4fVectorData: (list, False, imath.Color4f),
189+
IECore.Color4fVectorData: (list, True, imath.Color4f),
190190
#IECore.Color4dVectorData: (list, False, IECore.Color4d),
191191

192192
IECore.CompoundData: (dict, True, None),
@@ -245,6 +245,9 @@ def valueTypeFromSequenceType(sequenceType):
245245
## \ingroup python
246246
def dataTypeFromElementType(elementType):
247247

248+
if elementType is list:
249+
raise TypeError( "`list` type is ambiguous and not a valid input to dataTypeFromElementType()" )
250+
248251
for (dataType, value) in __dataTypesConversionDict.items():
249252
if value is None:
250253
continue
@@ -262,7 +265,9 @@ def dataTypeFromElement(element):
262265
# We have to check the list contents.
263266
elementValueType = type(element[0])
264267
for (dataType, value) in __dataTypesConversionDict.items():
265-
if value[0] is list and len(value) >= 2 and value[2] is elementValueType:
268+
if value is None:
269+
continue
270+
if value[0] is list and len(value) >= 2 and value[1] and value[2] is elementValueType:
266271
return dataType
267272

268273
return dataTypeFromElementType(type(element))

src/IECore/FrameRange.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ FrameRange::FrameRange( Frame start, Frame end, Frame step ) : m_start( start ),
5858
{
5959
throw Exception( "FrameRange step cannot be zero" );
6060
}
61+
if ( step < 0 )
62+
{
63+
throw Exception( "FrameRange step cannot be negative. Consider using the reverse suffix instead." );
64+
}
6165
}
6266

6367
FrameRange::~FrameRange()
@@ -102,6 +106,10 @@ void FrameRange::setStep( Frame step )
102106
{
103107
throw Exception( "FrameRange step cannot be zero" );
104108
}
109+
if ( step < 0 )
110+
{
111+
throw Exception( "FrameRange step cannot be negative. Consider using the reverse suffix instead." );
112+
}
105113
m_step = step;
106114
}
107115

test/IECore/DataTraitsTest.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#
3333
##########################################################################
3434

35-
import math
3635
import unittest
3736
import IECore
38-
import random
39-
import os
37+
import datetime
38+
import imath
39+
4040

4141
class DataTraitsTest( unittest.TestCase ) :
4242

@@ -129,6 +129,65 @@ def testIsSequenceDataType( self ) :
129129
for data in falseData :
130130
self.assertFalse( IECore.DataTraits.isSequenceDataType( data ) )
131131

132+
def testDataFromElement( self ) :
133+
134+
dataMap = (
135+
( True, IECore.BoolData, IECore.BoolVectorData ),
136+
( 10, IECore.IntData, IECore.IntVectorData ),
137+
( "abc", IECore.StringData, IECore.StringVectorData ),
138+
( IECore.InternedString( "abc" ), IECore.InternedStringData, IECore.InternedStringVectorData ),
139+
( 1.1, IECore.DoubleData, IECore.DoubleVectorData ),
140+
( imath.V2f( 1.0, 2.0 ), IECore.V2fData, IECore.V2fVectorData ),
141+
( imath.V2d( 1.0, 2.0 ), IECore.V2dData, IECore.V2dVectorData ),
142+
( imath.V2i( 1, 2 ), IECore.V2iData, IECore.V2iVectorData ),
143+
( imath.V3i( 1, 2, 3 ), IECore.V3iData, IECore.V3iVectorData ),
144+
( imath.V3f( 1.0, 2.0, 3.0 ), IECore.V3fData, IECore.V3fVectorData ),
145+
( imath.V3d( 1.0, 2.0, 3.0 ), IECore.V3dData, IECore.V3dVectorData ),
146+
( imath.Quatf(), IECore.QuatfData, IECore.QuatfVectorData ),
147+
( imath.Quatd(), IECore.QuatdData, IECore.QuatdVectorData ),
148+
( imath.Color3f(), IECore.Color3fData, IECore.Color3fVectorData ),
149+
( imath.Color4f(), IECore.Color4fData, IECore.Color4fVectorData ),
150+
( imath.Box2i(), IECore.Box2iData, IECore.Box2iVectorData ),
151+
( imath.Box3i(), IECore.Box3iData, IECore.Box3iVectorData ),
152+
( imath.Box2f(), IECore.Box2fData, IECore.Box2fVectorData ),
153+
( imath.Box2d(), IECore.Box2dData, IECore.Box2dVectorData ),
154+
( imath.Box3f(), IECore.Box3fData, IECore.Box3fVectorData ),
155+
( imath.Box3d(), IECore.Box3dData, IECore.Box3dVectorData ),
156+
( imath.M33f(), IECore.M33fData, IECore.M33fVectorData ),
157+
( imath.M33d(), IECore.M33dData, IECore.M33dVectorData ),
158+
( imath.M44f(), IECore.M44fData, IECore.M44fVectorData ),
159+
( imath.M44d(), IECore.M44dData, IECore.M44dVectorData ),
160+
( { "age" : 10 }, IECore.CompoundData, None ),
161+
( IECore.TransformationMatrixf(), IECore.TransformationMatrixfData, None ),
162+
( IECore.TransformationMatrixd(), IECore.TransformationMatrixdData, None ),
163+
( IECore.LineSegment3f( imath.V3f( 0 ), imath.V3f( 1 ) ), IECore.LineSegment3fData, None ),
164+
( IECore.LineSegment3d( imath.V3d( 0 ), imath.V3d( 1 ) ), IECore.LineSegment3dData, None ),
165+
( IECore.Splineff(), IECore.SplineffData, None ),
166+
( IECore.Splinedd(), IECore.SplineddData, None ),
167+
( IECore.SplinefColor3f(), IECore.SplinefColor3fData, None ),
168+
( IECore.SplinefColor4f(), IECore.SplinefColor4fData, None ),
169+
( datetime.datetime( 2023, 7, 14 ), IECore.DateTimeData, None ),
170+
( IECore.TimeCode(), IECore.TimeCodeData, None ),
171+
( IECore.PathMatcher(), IECore.PathMatcherData, None ),
172+
)
173+
174+
for element, dataType, vectorType in dataMap :
175+
# test single element conversion
176+
self.assertEqual( IECore.dataFromElement( element ), dataType( element ) )
177+
if vectorType is None :
178+
continue
179+
180+
# test list of elements conversion to a vector data
181+
self.assertEqual(
182+
IECore.dataFromElement( [ element ] ),
183+
vectorType( [ element ] ),
184+
)
185+
186+
def testDataTypeFromElementType( self ) :
187+
self.assertEqual( IECore.dataTypeFromElementType( int ) , IECore.IntData )
188+
self.assertRaises( TypeError, IECore.dataTypeFromElementType, list )
189+
190+
132191
if __name__ == "__main__":
133-
unittest.main()
192+
unittest.main()
134193

test/IECore/FrameList.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,24 @@ def testReverseConstruction( self ) :
5555
self.assertEqual( f.asList(), [ 5, 4, 3, 2, 1 ] )
5656
self.assertEqual( IECore.frameListFromList( [ 5, 4, 3, 2, 1 ] ), f )
5757

58+
def testFrameRange( self ) :
59+
60+
f = IECore.FrameList.parse( "1-5" )
61+
self.assertTrue( isinstance( f, IECore.FrameRange ) )
62+
self.assertEqual( f.asList(), [ 1, 2, 3, 4, 5 ] )
63+
# test step
64+
f = IECore.FrameList.parse( "10-20x5" )
65+
self.assertTrue( isinstance( f, IECore.FrameRange ) )
66+
self.assertEqual( f.asList(), [ 10, 15, 20 ] )
67+
# start must be smaller or equal to end
68+
self.assertRaises( Exception, IECore.FrameList.parse, "5-1" )
69+
# step must be positive
70+
self.assertRaises( Exception, IECore.FrameList.parse, "1-5x0" )
71+
self.assertRaises( Exception, IECore.FrameList.parse, "1-5x-1" )
72+
self.assertRaises( Exception, IECore.FrameList.parse, "5-1x-1" )
73+
74+
5875
## \todo: there should probably be a lot more tests in here...
5976

6077
if __name__ == "__main__":
61-
unittest.main()
78+
unittest.main()

0 commit comments

Comments
 (0)