Repository navigation
Review the unit tests and fix the bugs they found - #193
Merged
Merged
Conversation
Remove tests that restate the code (getters, defaults, declarative pydantic bounds without custom validators), tests without assertions, direction-only checks implied by reference values, and copies of inherited behavior; merge the per-fixture size checks of the catalog into one test over every fixture. Run test_rise_and_set_times_are_refined, which was nested under the __main__ guard and never collected.
mean_anomaly_to_true_anomaly and true_anomaly_to_mean_anomaly solve Kepler's equation (Newton's method) rather than approximate it with a third-order series, which erred by about 11 deg at the eccentricity of Molniya orbits and placed members of eccentric constellations off their mean anomalies. The tests check Vallado's Example 2-1, the inversion of the conversions at high eccentricities, and a Molniya member's position a quarter period ahead of its lead.
Check expected values derived independently of the code under test (analytic geometry, skyfield, hand-derived Walker spacings, brute-force Pareto fronts) where tests checked only ranges, types, or counts, or could not fail, and add the missing check of mirrored instruments under a yawed target attitude.
compute_j2_raan_rate, compute_j2_aop_rate, and compute_j2_mean_motion_rate scale J2 by the equatorial radius, to which it is normalized, rather than the mean radius (about 0.22% too slow). The tests check Vallado's secular mean anomaly rate and the sun-synchronous rate at Landsat's altitude.
get_copernicus_dem_tile_urls wraps tiles across the antimeridian, limits them to the tiles' latitudes, covers every longitude about a pole, and spans the exact longitudes of a spherical cap. compute_terrain_mask reads terrain across the antimeridian and sample_dem_elevation wraps longitudes.
Add the J2, DEM, and pandas fixes to the change log.
On the test's conditional design space, NSGA-II samples the same designs as random sampling (it relates only the decisions every trial makes), so the test could not detect a broken optimizer. The test searches with the default sampler (TPE), checks that each trial is told the means of its design in the directions of the objectives, and that the search finds more of the true front's hypervolume than random sampling of the same seed. The docstring of optimize_optuna notes the limitation of such samplers.
…atencyNOAA20 ValidateLatencyNOAA20 and ValidateOrbitGeneration both cached TLEs as data/orbits/weather.tle: the NOAA-20 element set of the latency notebook's day made ValidateOrbitGeneration fail without the rest of the group.
…eir longitudes The generated geosynchronous orbits start at the requested longitudes since their node is solved for the longitude at the epoch; the table's longitudes at epoch (computed with the current code, whose 30-day changes are unchanged) and the text no longer show the offset of 0.013 deg of earlier versions.
…itGeneration found
…validation notebooks Trim the numbers from the fixed entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reviews the unit tests, removing trivial and redundant ones and tightening weak assertions, and fixes the bugs the review found.
Unit tests
*_pixels.npzfixtures that were not checked). No test that was the only coverage of a function, argument, or branch was removed.test_rise_and_set_times_are_refined(intests/schemas/orbit/test_gp.py), which was nested under the__main__guard and never collected.Fixes
mean_anomaly_to_true_anomalyandtrue_anomaly_to_mean_anomalysolve Kepler's equation (Newton's method) instead of a third-order series, which was inaccurate at high eccentricities: members of Molniya, Tundra, and Keplerian constellations (get_derived_orbit) were placed off their mean anomalies.compute_j2_raan_rate,compute_j2_aop_rate, andcompute_j2_mean_motion_ratescale J2 by the equatorial radius, to which it is normalized, instead of the mean radius. Molniya and Tundra periods (refined by SGP4) are unchanged.get_copernicus_dem_tile_urlswraps tiles across the antimeridian, limits them to the tiles' latitudes, covers every longitude about a pole, and spans a spherical cap's longitudes exactly;compute_terrain_maskreads terrain across the antimeridian, andsample_dem_elevationwraps longitudes past 180.tatc.visualizationfills missing ends of periods in nanoseconds, removing a pandas 4 deprecation warning.Documentation and validation notebooks
optimize_optunadocuments that samplers relating decisions across trials (such as NSGA-II) sample conditional decisions at random.ValidateLatencyNOAA20caches its NOAA-20 element set in its own file; it shareddata/orbits/weather.tlewithValidateOrbitGeneration, which then failed without the rest of the weather group.ValidateOrbitGenerationshows geosynchronous orbits starting at their longitudes (fixed in 3.9.0; its table's longitudes at epoch are recomputed with the current code) and lists the earlier offset among the errors it found. The notebook was not rerun: its October 2026 element sets are no longer cached, and a rerun with current CelesTrak element sets changes results unrelated to this branch (on the same element sets, the Kepler fix changes only its Molniya apogee drift rates, within the range its text states).Testing
The full suite passes, also with pandas 4 deprecation warnings as errors, and
black --checkis clean. The new tests of the fixes fail on the previous code.