Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void define_imath_2d(py::module m) {
// Imath classes are binded with Pybind11 more than once.
// Using module_local will avoid conflicts in such cases.
py::class_<IMATH_NAMESPACE::V2d>(m, "V2d", py::module_local())
.def(py::init<>())
.def(py::init<>([]() { return IMATH_NAMESPACE::V2d(0.0, 0.0); }))
.def(py::init<double>())
.def(py::init<double, double>())
.def_readwrite("x", &IMATH_NAMESPACE::V2d::x)
Expand Down Expand Up @@ -101,7 +101,7 @@ static void define_imath_2d(py::module m) {
});

py::class_<IMATH_NAMESPACE::Box2d>(m, "Box2d", py::module_local())
.def(py::init<>())
.def(py::init<>([]() { return IMATH_NAMESPACE::Box2d(IMATH_NAMESPACE::V2d(0.0, 0.0)); }))
.def(py::init<IMATH_NAMESPACE::V2d>())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reinecke In the meeting today we were wondering if this also needs to be initialized:

.def(py::init<IMATH_NAMESPACE::V2d>())

I believe this is OK as is, since this constructs a Box2d from a V2d. Since the V2d is now initialized to zero with this change, the Box2d will also be initialized to zero:

v = otio.schema.V2d() # initialized to zero
box = otio.schema.Box2d(v) # also initialized to zero

.def(py::init<IMATH_NAMESPACE::V2d, IMATH_NAMESPACE::V2d>())
.def_readwrite("min", &IMATH_NAMESPACE::Box2d::min)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_box2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

class Box2dTests(unittest.TestCase, otio_test_utils.OTIOAssertions):
def test_cons(self):
box = otio.schema.Box2d()

self.assertEqual(box.min, otio.schema.V2d(0.0, 0.0))
self.assertEqual(box.max, otio.schema.V2d(0.0, 0.0))

v1 = otio.schema.V2d(1.0, 2.0)
v2 = otio.schema.V2d(3.0, 4.0)
box = otio.schema.Box2d(v1, v2)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_v2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

class V2dTests(unittest.TestCase, otio_test_utils.OTIOAssertions):
def test_cons(self):
v = otio.schema.V2d()

self.assertEqual(v.x, 0.0)
self.assertEqual(v.y, 0.0)

v = otio.schema.V2d(1.0, 2.0)

self.assertEqual(v.x, 1.0)
Expand Down
Loading