Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overload RationalTime.from_seconds with additional rate argument #1118

Merged

Conversation

apetrynet
Copy link
Contributor

Closes #818

Summarize your change.

Work in progress!!
I'm in over my head here so hacking together an attempt.

Overload RationalTime.from_seconds with an additional "rate" argument to avoid having to rescale value to target rate.

Before PR:

now = datetime.datetime.now()
tod = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds()
rt = otio.opentime.from_seconds(tod).rescaled_to(24)

After PR:

now = datetime.datetime.now()
tod = (now - now.replace(hour=0, minute=0, second=0, microsecond=0)).total_seconds()
rt = otio.opentime.from_seconds(tod, 24)

Reference associated tests.

Tests will be added to the unittests

@codecov-commenter
Copy link

Codecov Report

Merging #1118 (81f9a21) into master (0cc00ce) will decrease coverage by 0.01%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1118      +/-   ##
==========================================
- Coverage   86.20%   86.19%   -0.02%     
==========================================
  Files         191      191              
  Lines       19028    19049      +21     
  Branches     2105     2104       -1     
==========================================
+ Hits        16404    16420      +16     
- Misses       2078     2083       +5     
  Partials      546      546              
Flag Coverage Δ
unittests 86.19% <87.50%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
...lineio/opentime-bindings/opentime_rationalTime.cpp 96.05% <71.42%> (+0.05%) ⬆️
src/opentime/rationalTime.h 90.19% <100.00%> (+0.40%) ⬆️
tests/test_opentime.py 99.72% <100.00%> (+<0.01%) ⬆️
src/opentimelineio/serializableObject.cpp 63.85% <0.00%> (-4.98%) ⬇️
src/opentime/errorStatus.h 100.00% <0.00%> (ø)
src/opentimelineio/typeRegistry.h 100.00% <0.00%> (ø)
src/opentimelineio/stringUtils.cpp 66.66% <0.00%> (ø)
src/opentimelineio/deserialization.cpp 60.33% <0.00%> (ø)
src/opentimelineio/serializableObject.h 89.58% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

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

@apetrynet
Copy link
Contributor Author

apetrynet commented Oct 24, 2021

Hi!

All tests seem to pass so I'd like some feedback on this PR. What I'm most concerned about is the pybind11 stuff and if I'm introducing memory leaks etc.
The changes done to the python bindings were done based on tips from this stackoverflow post.

And please let me know if the PR should go back to draft. The review request seemed to remove the draft status.

@apetrynet apetrynet marked this pull request as ready for review October 24, 2021 20:55
Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

Looks good, but what do you think about a simpler unit test? Or was there something specific you wanted to achieve with the datetime approach?

tests/test_opentime.py Outdated Show resolved Hide resolved
tests/test_opentime.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks @apetrynet!

-Stephan.

@ssteinbach ssteinbach merged commit 466a9b5 into AcademySoftwareFoundation:master Oct 25, 2021
@ssteinbach ssteinbach added this to the Public Beta 14 milestone Oct 25, 2021
@apetrynet apetrynet deleted the from_seconds_rate branch November 28, 2022 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question about opentime.from_seconds argument(s)
3 participants