-
-
Notifications
You must be signed in to change notification settings - Fork 31
Non-leap time scales error on init with leap second #411
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
Non-leap time scales error on init with leap second #411
Conversation
Previously, one could initialize an Epoch with the 60th second on a leap day even if the selected time scale did not support leap seconds. This PR makes this an error. Importantly, this PR also fixes an error in the `julian_epoch` test where an epoch was initialized on the leap second but ... in TAI. There is no leap second in TAI, so this initialization should fail. The test case was also expanded to confirm the computation of Modified Julian Dates using NASA HEASARC, with an extra test and a clarification that leap second management is implementation dependent.
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.
Summary of Changes
Hello @ChristopherRabotin, 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 enhances the robustness of time handling within the Epoch system by enforcing stricter validation during initialization, specifically concerning leap seconds in non-leap-second time scales. It also refines and expands the test suite to ensure the accuracy of Modified Julian Date (MJD) calculations and to explicitly test for invalid date inputs, improving overall reliability.
Highlights
- Time Scale Validation: I've implemented a check within the
Epoch::from_gregorian_hmsconstructor to prevent initialization with a 60th second (representing a leap second) if the specifiedTimeScaledoes not support leap seconds. This now correctly returns anInvalidGregorianDateerror in such cases. - Leap Second Test Correction and Expansion: I've corrected the
julian_epochtest by switching from TAI (International Atomic Time, which does not have leap seconds) to UTC (Coordinated Universal Time, which does) for leap second related MJD calculations. Additionally, I've expanded these tests to include verification against NASA HEASARC data and added clarifying comments regarding the implementation-dependent nature of leap second handling. - New Regression Tests: I've added two new
#[should_panic]tests. One specifically validates that attempting to initialize anEpochwith 60 seconds in a non-leap-second time scale (like TAI) correctly panics. The other confirms that initializing anEpochwith an invalid Gregorian date (e.g., February 31st) also results in a panic.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 or fill out our survey to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 adds a check to prevent initializing an epoch with a leap second for time scales that do not support them. The tests are updated accordingly, including fixing a bug in an existing test and adding a new regression test. My review focuses on improving test code maintainability by removing a duplicated test and a magic number.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #411 +/- ##
=======================================
Coverage 82.68% 82.68%
=======================================
Files 24 24
Lines 3569 3570 +1
=======================================
+ Hits 2951 2952 +1
Misses 618 618 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I've reviewed the changes "à tête reposée" and agree with them, so I'll go ahead and merge this. |
Previously, one could initialize an Epoch with the 60th second on a leap day even if the selected time scale did not support leap seconds. This PR makes this an error.
Importantly, this PR also fixes an error in the
julian_epochtest where an epoch was initialized on the leap second but ... in TAI. There is no leap second in TAI, so this initialization should fail. The test case was also expanded to confirm the computation of Modified Julian Dates using NASA HEASARC, with an extra test and a clarification that leap second management is implementation dependent.Thanks for the report @ephraim71 !