Skip to content

Total time updaters #1520

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

Closed

Conversation

AntonBallmaier
Copy link
Contributor

@AntonBallmaier AntonBallmaier commented May 15, 2021

Changelog / Overview

  • Mobject.add_updater has a new parameter pass_relative_times determining if the updater should get passed relative or absolute time values.
  • Updaters can now have arbitraty named second parameters instead of requiring dt.
  • call_updater=True no longer causes an error with non-time-based updaters.
  • Renamed Mobject.update to Mobject._apply_updaters and deprecated update.

Motivation

From time to time you don't need the time difference since last updater call, but the total time... Now you without a problem.
Closes #321
Includes parts of the feature requested in #851

Explanation for Changes

Documentation Reference

Checklist

  • I have read the Contributing Guidelines
  • I have written a descriptive PR title (see top of PR template for examples)
  • I have written a changelog entry for the PR or deem it unnecessary
  • My new functions/classes either have a docstring or are private
  • My new functions/classes have tests added and (optional) examples in the docs
  • My new documentation builds, looks correctly formatted, and adds no additional build warnings

Reviewer Checklist

  • The PR title is descriptive enough
  • The PR is labeled correctly
  • The changelog entry is completed if necessary
  • Newly added functions/classes either have a docstring or are private
  • Newly added functions/classes have tests added and (optional) examples in the docs
  • Newly added documentation builds, looks correctly formatted, and adds no additional build warnings

@AntonBallmaier AntonBallmaier added pr:bugfix Bug fix for use in PRs solving a specific issue:bug pr:deprecation Deprecation, or removal of deprecated code new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) labels May 15, 2021
Copy link
Member

@jsonvillanueva jsonvillanueva left a comment

Choose a reason for hiding this comment

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

pre-commit is complaining about these -- applying these changes

Applied pre-commit suggestions
Copy link
Member

@jsonvillanueva jsonvillanueva left a comment

Choose a reason for hiding this comment

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

In general, this PR functions as intended from my tests/usage of the new feature. I'll approve now as it works and this could be added to the 0.7.0 release, but I've offered some suggestions to consider.

Comment on lines +865 to +870
pass_relative_times
Whether the time information passed to the updater should be relative
(usually the time since last call) or absolute (sum of all relative times
since the updater was added). If ``pass_relative_times`` is ``None``
relative times get passed, except if the second parameter of the updater is
named ``t`` or ``time``.
Copy link
Member

@jsonvillanueva jsonvillanueva May 31, 2021

Choose a reason for hiding this comment

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

I'd rather pass_relative_times have a default argument of True than be None and later make it False if necessary. Also, I don't particularly like the feature of changing the updater to total time if the second argument is t /time... seems a bit hacky.

update_function: Updater,
updater: Updater,
*,
pass_relative_times: Optional[bool] = None,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pass_relative_times: Optional[bool] = None,
pass_relative_times: optional[bool] = True,

Comment on lines +924 to +926
if parameters[1] not in ["t", "time"] and pass_relative_times is None:
pass_relative_times = True
pass_relative_times = bool(pass_relative_times)
Copy link
Member

Choose a reason for hiding this comment

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

again, I don't particularly like this hard coded check for the second argument, but with a default of True, you can simplify the logic to only check for if it should be set to False

Suggested change
if parameters[1] not in ["t", "time"] and pass_relative_times is None:
pass_relative_times = True
pass_relative_times = bool(pass_relative_times)
if parameters[1] in ["t", "time"]:
pass_relative_times = False

@Darylgolden
Copy link
Member

Hi, are you still planning on working on this?

@MrDiver
Copy link
Collaborator

MrDiver commented Jun 18, 2022

We will come back to this with a fresh view if the issue get's relevant again. This PR is already linked in the original issue

So i will close this for now. Feel free to open this PR again or a new PR which fixes the issue if you want to work on it again!

@MrDiver MrDiver closed this Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) pr:bugfix Bug fix for use in PRs solving a specific issue:bug pr:deprecation Deprecation, or removal of deprecated code
Projects
Status: Rejected
Development

Successfully merging this pull request may close these issues.

Deprecate different signatures for updaters
4 participants