-
Notifications
You must be signed in to change notification settings - Fork 136
Improve Test Coverage and Refactor Test for mslib.utils.coordinate #2596
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
Open
saiabhinav001
wants to merge
9
commits into
Open-MSS:develop
Choose a base branch
from
saiabhinav001:patch-1
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+101
−143
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
058ca45
Add comprehensive test suite for `mslib.utils.coordinate` module
saiabhinav001 7beb9c2
Update test_coordinate.py
saiabhinav001 066ca2d
Update test_coordinate.py
saiabhinav001 77c51f9
Update test_coordinate.py
saiabhinav001 4416fd5
Update test_coordinate.py
ReimarBauer 0573718
Update test_coordinate.py
ReimarBauer c6b3c03
Update test_coordinate.py
ReimarBauer 5c5258a
Update test_coordinate.py
saiabhinav001 907fb3b
Update test_coordinate.py
ReimarBauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| tests._test_utils.test_coordinate | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| This module provides pytest functions to tests mslib.utils.coordinate | ||
| This module provides pytest functions to test mslib.utils.coordinate. | ||
|
|
||
| This file is part of MSS. | ||
|
|
||
|
|
@@ -24,11 +24,12 @@ | |
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| """ | ||
|
|
||
| import logging | ||
| import datetime | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
| import pytest # type: ignore | ||
|
|
||
| import mslib.utils.coordinate as coordinate | ||
| from mslib.utils.find_location import find_location | ||
|
|
@@ -39,13 +40,13 @@ | |
|
|
||
| class TestGetDistance: | ||
| """ | ||
| tests for distance based calculations | ||
| Tests for distance-based calculations. | ||
| """ | ||
| # we don't test the utils method here, may be that method should me refactored off | ||
|
|
||
| def test_get_distance(self): | ||
| coordinates_distance = [(50.355136, 7.566077, 50.353968, 4.577915, 212), | ||
| (-5.135943, -42.792442, 4.606085, 120.028077, 18130)] | ||
| coordinates_distance = [ | ||
| (50.355136, 7.566077, 50.353968, 4.577915, 212), | ||
| (-5.135943, -42.792442, 4.606085, 120.028077, 18130) | ||
| ] | ||
| for lat0, lon0, lat1, lon1, distance in coordinates_distance: | ||
| assert int(coordinate.get_distance(lat0, lon0, lat1, lon1)) == distance | ||
|
|
||
|
|
@@ -67,9 +68,8 @@ def test_get_projection_params(self): | |
|
|
||
| class TestAngles: | ||
| """ | ||
| tests about angles | ||
| Tests for angle-related calculations. | ||
| """ | ||
|
|
||
| def test_normalize_angle(self): | ||
| assert coordinate.fix_angle(0) == 0 | ||
| assert coordinate.fix_angle(180) == 180 | ||
|
|
@@ -80,14 +80,15 @@ def test_normalize_angle(self): | |
| assert coordinate.fix_angle(420) == 60 | ||
|
|
||
| def test_rotate_point(self): | ||
| assert coordinate.rotate_point([0, 0], 0) == (0.0, 0.0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see why the old tests should be removed. They provide coverage for corner cases and have no issues with decimal points. The new test is a good addition, though. |
||
| assert coordinate.rotate_point([0, 0], 180) == (0.0, 0.0) | ||
| assert coordinate.rotate_point([1, 0], 0) == (1.0, 0.0) | ||
| assert coordinate.rotate_point([100, 90], 90) == (-90, 100) | ||
| point = [0.0, 2.5] | ||
| angle = 45 | ||
| rotated_point = (-1.7678, 1.7678) | ||
|
|
||
| assert coordinate.rotate_point(point, angle) == pytest.approx(rotated_point, rel=1e-6, abs=1e-6) | ||
|
|
||
|
|
||
| class TestLatLonPoints: | ||
| def test_linear(self): | ||
| def test_linear(self): | ||
| ref_lats = [0, 10] | ||
| ref_lons = [0, 0] | ||
|
|
||
|
|
@@ -112,12 +113,6 @@ def test_linear(self): | |
| assert len(lons) == 3 | ||
| assert all(lons == [0, 5, 10]) | ||
|
|
||
| lats, lons = coordinate.latlon_points(ref_lats[0], ref_lons[0], ref_lats[1], ref_lons[1], | ||
| numpoints=3, connection="linear") | ||
| assert len(lats) == 3 | ||
| assert len(lons) == 3 | ||
| assert all(lons == [0, 5, 10]) | ||
|
|
||
| def test_greatcircle(self): | ||
| ref_lats = [0, 10] | ||
| ref_lons = [0, 0] | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
this type: ignore is new here. What is it doing, just my interests in it. What is the reason for this?
the linter will likly want two blanks to seperate the comment
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.
I think that is not good to add it here. When we have type related issues, we won't see that now, correnct?