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 Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.00%. Comparing base (c0e97b0) to head (1ec7fcb).
⚠️ Report is 77 commits behind head on main.

❌ Your changes status has failed because you have indirect coverage changes. Learn more about Unexpected Coverage Changes and reasons for indirect coverage changes.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1956      +/-   ##
==========================================
+ Coverage   84.11%   85.00%   +0.88%     
==========================================
  Files         198      181      -17     
  Lines       22241    13080    -9161     
  Branches     4687     1206    -3481     
==========================================
- Hits        18709    11119    -7590     
+ Misses       2610     1778     -832     
+ Partials      922      183     -739     
Flag Coverage Δ
py-unittests 85.00% <100.00%> (+0.88%) ⬆️

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 91.66% <100.00%> (-0.93%) ⬇️
tests/test_box2d.py 96.07% <100.00%> (+0.24%) ⬆️
tests/test_v2d.py 97.56% <100.00%> (+0.45%) ⬆️

... and 138 files with indirect coverage changes


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 19d12b8...1ec7fcb. Read the comment docs.

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

Comment on lines 105 to 106
.def(py::init<IMATH_NAMESPACE::V2d>())
.def(py::init<IMATH_NAMESPACE::V2d, IMATH_NAMESPACE::V2d>())
Copy link
Collaborator

@reinecke reinecke Oct 23, 2025

Choose a reason for hiding this comment

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

Looks like there may be a couple sneaky ones!

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