Fix inverted coordinate conversion in test_top_bottom_point - #108
Merged
Conversation
Point.bounds is NZTM, but the test built it with nztm_to_wgs_depth applied to a value that is already a WGS lat/lon, running the conversion backwards. The resulting point sat at (-75.8, 82.9) rather than (-43.0, 172.0). The test still passed because it only asserts on top_m and bottom_m, which depend solely on the depth component, and nztm_to_wgs_depth leaves depth untouched. Adds a round-trip assertion on point.coordinates so the horizontal components are actually checked. Fixes #95 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #95
Problem
test_top_bottom_pointran the coordinate conversion backwards:Point.boundsis documented as NZTM (sources.py:37-38) andPoint.from_lat_lon_depthbuilds it withcoordinates.wgs_depth_to_nztm(...). The literal here is already a WGS lat/lon, so applyingnztm_to_wgs_depthto it produces neither valid NZTM nor the intended location:Why it passed anyway
The test only asserts on
point.top_mandpoint.bottom_m, which depend solely on the depth component — andnztm_to_wgs_depthpasses depth through untouched.top_m/bottom_mare byte-identical either way, so the assertions were satisfied no matter how wrong the horizontal position was. The test did not exercise what it appeared to, and the construction is the kind of thing that gets copied into a test that does use the horizontal position.Changes
coordinates.wgs_depth_to_nztm(...).assert np.allclose(point.coordinates, point_coordinates)so the horizontal components are actually pinned down.Verification
pytest tests/test_sources.py— 64 passed.ruff check,ruff formatclean.🤖 Generated with Claude Code