-
-
Notifications
You must be signed in to change notification settings - Fork 103
Fix SmoothingETA #304
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
base: develop
Are you sure you want to change the base?
Fix SmoothingETA #304
Conversation
Summary of ChangesHello @jonathanpoelen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly fixes a bug in SmoothingETA where the return value of smoothing_algorithm.update() was ignored, making the widget behave identically to ETA. The fix is correct and the tests have been updated accordingly.
Your analysis in the pull request description raises several excellent points about the library's design that are worth addressing:
SmoothingETAConstructor: Your suggestion to refactor theSmoothingETAconstructor to accept an instantiatedSmoothingAlgorithmobject is a great idea. It would improve the API's flexibility and testability, following the Dependency Inversion Principle.AdaptiveETAUnused Parameters: You are correct thatexponential_smoothingandexponential_smoothing_factorinAdaptiveETAappear to be unused. This dead code should be removed.- Monotonic Time: Your point about
time.time()not being monotonic is critical. For accurate duration calculations, the library should usetime.monotonic()to avoid bugs related to system time adjustments.
These are valuable insights that would significantly improve the library. I recommend addressing them in separate, follow-up pull requests. This PR is good to merge as is for the immediate bug fix.
|
Very good catch! That does look like an improvement. I'm going to test it and get back to you. With regards to monotonic, that would be a good idea indeed. I remember not using monotonic back when I wrote the code because it wasn't universally available, but I believe that's no longer the case so we can safely use it now. The smoothing parameters is a legacy thing... I think I should just hide it with kwargs. It's basically meant to not break older code. |
The value of
smoothing_algorithm.update()was not used, thereforeSmoothingETAwas strictly identical toETA.I would like to take this opportunity to say that the constructor of
SmoothingETAis particularly bad and incorrect in terms of typing:smoothing_parameterscontradictsalgorithms.SmoothingAlgorithm.__init__, which takes adict[str, Any]. This typing also forces all inherited classes to use floats as parameters. This doesn't make sense. Furthermore, the constructor ofalgorithms.SmoothingAlgorithmthrows an exception and forces you to create a__init__function, even if it's not useful.algorithms.SmoothingAlgorithmshouldn't have a constructor.The constructor of
SmoothingETAshould simply take an instance ofalgorithms.SmoothingAlgorithmand not have this horriblesmoothing_parameters, which also makes IDE auto-completion unusable.While I'm at it, what are the
exponential_smoothingandexponential_smoothing_factormembers and parameters ofAdaptiveETA, since they are not used?One last thing that's unrelated:
time.time()is not monotonic, which creates bugs twice a year following daylight saving time changes or when there is an NTP synchronization that set back.