Skip to content

Conversation

@darbyjohnston
Copy link
Contributor

This PR initializes Imath values created in Python to 0.0. In C++ the default constructor does not initialize the values which means they could be anything. This is done as an optimization for C++ but is probably not necessary and also unexpected in Python.

For example this was recently causing CI failures: #1955

Signed-off-by: Darby Johnston <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.11%. Comparing base (829a913) to head (c8149c5).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1956   +/-   ##
=======================================
  Coverage   85.10%   85.11%           
=======================================
  Files         181      181           
  Lines       12768    12774    +6     
  Branches     1206     1206           
=======================================
+ Hits        10866    10872    +6     
  Misses       1719     1719           
  Partials      183      183           
Flag Coverage Δ
py-unittests 85.11% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ntimelineio/opentimelineio-bindings/otio_imath.cpp 92.59% <100.00%> (ø)
tests/test_box2d.py 96.07% <100.00%> (+0.24%) ⬆️
tests/test_v2d.py 97.56% <100.00%> (+0.09%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 829a913...c8149c5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants