Skip to content

Commit 3cefa62

Browse files
authored
fix: Fixups for new TypeURational after PR #5036 (#5057)
PR #5036 incidentally added a new TypeURational alias, but I neglected to make the corresponding change on the Python bindings, to update some of the docs, or to fully test it. This PR completes those items. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 21dbd07 commit 3cefa62

7 files changed

Lines changed: 50 additions & 39 deletions

File tree

src/doc/imageioapi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ in the outer OpenImageIO scope:
5151
TypeFloat2 TypeVector2 TypeVector2i TypeVector3i TypeFloat4
5252
TypeString TypeTimeCode TypeKeyCode
5353
TypeBox2 TypeBox2i TypeBox3 TypeBox3i
54-
TypeRational TypePointer TypeUstringhash
54+
TypeRational TypeURational TypePointer TypeUstringhash
5555

5656
The only types commonly used to store *pixel values* in image files
5757
are scalars of ``UINT8``, ``UINT16``, `float`, and ``half``.

src/doc/pythonbindings.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ described in detail in Section :ref:`sec-typedesc`, is replicated for Python.
128128
TypeFloat2 TypeVector2 TypeFloat4
129129
TypeVector2i TypeVector3i
130130
TypeMatrix TypeMatrix33
131-
TypeTimeCode TypeKeyCode TypeRational TypePointer
131+
TypeTimeCode TypeKeyCode TypeRational TypeURational
132+
TypePointer
132133
133134
Pre-constructed `TypeDesc` objects for some common types, available in the
134135
outer OpenImageIO scope.

src/libutil/typedesc_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ main(int /*argc*/, char* /*argv*/[])
202202
TypeDesc(TypeDesc::INT, TypeDesc::VEC2,
203203
TypeDesc::RATIONAL),
204204
TypeRational, i2, "1/2");
205+
uint32_t ui2[2] = { 1, 2 };
206+
test_type<uint32_t[2]>("urational",
207+
TypeDesc(TypeDesc::UINT32, TypeDesc::VEC2,
208+
TypeDesc::RATIONAL),
209+
TypeURational, ui2, "1/2");
205210
test_type<Imath::Box2f>("box2",
206211
TypeDesc(TypeDesc::FLOAT, TypeDesc::VEC2,
207212
TypeDesc::BOX, 2),

src/python/py_typedesc.cpp

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -141,41 +141,42 @@ declare_typedesc(py::module& m)
141141
py::implicitly_convertible<py::str, TypeDesc>();
142142

143143
// Global constants of common TypeDescs
144-
m.attr("TypeUnknown") = TypeUnknown;
145-
m.attr("TypeFloat") = TypeFloat;
146-
m.attr("TypeColor") = TypeColor;
147-
m.attr("TypePoint") = TypePoint;
148-
m.attr("TypeVector") = TypeVector;
149-
m.attr("TypeNormal") = TypeNormal;
150-
m.attr("TypeString") = TypeString;
151-
m.attr("TypeInt") = TypeInt;
152-
m.attr("TypeUInt") = TypeUInt;
153-
m.attr("TypeInt64") = TypeInt64;
154-
m.attr("TypeUInt64") = TypeUInt64;
155-
m.attr("TypeInt32") = TypeInt32;
156-
m.attr("TypeUInt32") = TypeUInt32;
157-
m.attr("TypeInt16") = TypeInt16;
158-
m.attr("TypeUInt16") = TypeUInt16;
159-
m.attr("TypeInt8") = TypeInt8;
160-
m.attr("TypeUInt8") = TypeUInt8;
161-
m.attr("TypeHalf") = TypeHalf;
162-
m.attr("TypeMatrix") = TypeMatrix;
163-
m.attr("TypeMatrix33") = TypeMatrix33;
164-
m.attr("TypeMatrix44") = TypeMatrix44;
165-
m.attr("TypeTimeCode") = TypeTimeCode;
166-
m.attr("TypeKeyCode") = TypeKeyCode;
167-
m.attr("TypeFloat2") = TypeFloat2;
168-
m.attr("TypeVector2") = TypeVector2;
169-
m.attr("TypeFloat4") = TypeFloat4;
170-
m.attr("TypeVector4") = TypeVector4;
171-
m.attr("TypeVector2i") = TypeVector2i;
172-
m.attr("TypeVector3i") = TypeVector3i;
173-
m.attr("TypeBox2") = TypeBox2;
174-
m.attr("TypeBox3") = TypeBox3;
175-
m.attr("TypeBox2i") = TypeBox2i;
176-
m.attr("TypeBox3i") = TypeBox3i;
177-
m.attr("TypeRational") = TypeRational;
178-
m.attr("TypePointer") = TypePointer;
144+
m.attr("TypeUnknown") = TypeUnknown;
145+
m.attr("TypeFloat") = TypeFloat;
146+
m.attr("TypeColor") = TypeColor;
147+
m.attr("TypePoint") = TypePoint;
148+
m.attr("TypeVector") = TypeVector;
149+
m.attr("TypeNormal") = TypeNormal;
150+
m.attr("TypeString") = TypeString;
151+
m.attr("TypeInt") = TypeInt;
152+
m.attr("TypeUInt") = TypeUInt;
153+
m.attr("TypeInt64") = TypeInt64;
154+
m.attr("TypeUInt64") = TypeUInt64;
155+
m.attr("TypeInt32") = TypeInt32;
156+
m.attr("TypeUInt32") = TypeUInt32;
157+
m.attr("TypeInt16") = TypeInt16;
158+
m.attr("TypeUInt16") = TypeUInt16;
159+
m.attr("TypeInt8") = TypeInt8;
160+
m.attr("TypeUInt8") = TypeUInt8;
161+
m.attr("TypeHalf") = TypeHalf;
162+
m.attr("TypeMatrix") = TypeMatrix;
163+
m.attr("TypeMatrix33") = TypeMatrix33;
164+
m.attr("TypeMatrix44") = TypeMatrix44;
165+
m.attr("TypeTimeCode") = TypeTimeCode;
166+
m.attr("TypeKeyCode") = TypeKeyCode;
167+
m.attr("TypeFloat2") = TypeFloat2;
168+
m.attr("TypeVector2") = TypeVector2;
169+
m.attr("TypeFloat4") = TypeFloat4;
170+
m.attr("TypeVector4") = TypeVector4;
171+
m.attr("TypeVector2i") = TypeVector2i;
172+
m.attr("TypeVector3i") = TypeVector3i;
173+
m.attr("TypeBox2") = TypeBox2;
174+
m.attr("TypeBox3") = TypeBox3;
175+
m.attr("TypeBox2i") = TypeBox2i;
176+
m.attr("TypeBox3i") = TypeBox3i;
177+
m.attr("TypeRational") = TypeRational;
178+
m.attr("TypeURational") = TypeURational;
179+
m.attr("TypePointer") = TypePointer;
179180
}
180181

181182
} // namespace PyOpenImageIO

src/python/stubs/OpenImageIO/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ TypeNormal: TypeDesc
6969
TypePoint: TypeDesc
7070
TypePointer: TypeDesc
7171
TypeRational: TypeDesc
72+
TypeURational: TypeDesc
7273
TypeString: TypeDesc
7374
TypeTimeCode: TypeDesc
7475
TypeUInt: TypeDesc

testsuite/python-typedesc/ref/out.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ type 'TypeHalf'
217217
c_str "half"
218218
type 'TypeRational'
219219
c_str "rational2i"
220+
type 'TypeURational'
221+
c_str "rational2ui"
220222
type 'TypeUInt'
221223
c_str "uint"
222224

testsuite/python-typedesc/src/test_typedesc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ def breakdown_test(t: oiio.TypeDesc, name="", verbose=True):
171171
breakdown_test (oiio.TypeVector2i, "TypeVector2i", verbose=False)
172172
breakdown_test (oiio.TypeVector3i, "TypeVector3i", verbose=False)
173173
breakdown_test (oiio.TypeHalf, "TypeHalf", verbose=False)
174-
breakdown_test (oiio.TypeRational, "TypeRational", verbose=False)
175-
breakdown_test (oiio.TypeUInt, "TypeUInt", verbose=False)
174+
breakdown_test (oiio.TypeRational, "TypeRational", verbose=False)
175+
breakdown_test (oiio.TypeURational, "TypeURational", verbose=False)
176+
breakdown_test (oiio.TypeUInt, "TypeUInt", verbose=False)
176177
print ("")
177178

178179
print ("Done.")

0 commit comments

Comments
 (0)