Skip to content

Commit 30f6f56

Browse files
Initialize Python Imath values (#1956)
Signed-off-by: Darby Johnston <[email protected]>
1 parent 04ab39c commit 30f6f56

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void define_imath_2d(py::module m) {
2828
// Imath classes are binded with Pybind11 more than once.
2929
// Using module_local will avoid conflicts in such cases.
3030
py::class_<IMATH_NAMESPACE::V2d>(m, "V2d", py::module_local())
31-
.def(py::init<>())
31+
.def(py::init<>([]() { return IMATH_NAMESPACE::V2d(0.0, 0.0); }))
3232
.def(py::init<double>())
3333
.def(py::init<double, double>())
3434
.def_readwrite("x", &IMATH_NAMESPACE::V2d::x)
@@ -101,7 +101,7 @@ static void define_imath_2d(py::module m) {
101101
});
102102

103103
py::class_<IMATH_NAMESPACE::Box2d>(m, "Box2d", py::module_local())
104-
.def(py::init<>())
104+
.def(py::init<>([]() { return IMATH_NAMESPACE::Box2d(IMATH_NAMESPACE::V2d(0.0, 0.0)); }))
105105
.def(py::init<IMATH_NAMESPACE::V2d>())
106106
.def(py::init<IMATH_NAMESPACE::V2d, IMATH_NAMESPACE::V2d>())
107107
.def_readwrite("min", &IMATH_NAMESPACE::Box2d::min)

tests/test_box2d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
class Box2dTests(unittest.TestCase, otio_test_utils.OTIOAssertions):
1111
def test_cons(self):
12+
box = otio.schema.Box2d()
13+
14+
self.assertEqual(box.min, otio.schema.V2d(0.0, 0.0))
15+
self.assertEqual(box.max, otio.schema.V2d(0.0, 0.0))
16+
1217
v1 = otio.schema.V2d(1.0, 2.0)
1318
v2 = otio.schema.V2d(3.0, 4.0)
1419
box = otio.schema.Box2d(v1, v2)

tests/test_v2d.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
class V2dTests(unittest.TestCase, otio_test_utils.OTIOAssertions):
1414
def test_cons(self):
15+
v = otio.schema.V2d()
16+
17+
self.assertEqual(v.x, 0.0)
18+
self.assertEqual(v.y, 0.0)
19+
1520
v = otio.schema.V2d(1.0, 2.0)
1621

1722
self.assertEqual(v.x, 1.0)

0 commit comments

Comments
 (0)