-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from ocefpaf/fixes_4
Fixes 4
- Loading branch information
Showing
7 changed files
with
306 additions
and
157 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-ast | ||
- id: debug-statements | ||
- id: check-added-large-files | ||
- id: requirements-txt-fixer | ||
- id: file-contents-sorter | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.1.0 | ||
hooks: | ||
- id: codespell | ||
exclude: > | ||
(?x)^( | ||
.*\.yaml | ||
)$ |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,68 +1,87 @@ | ||
import unittest | ||
import numpy as np | ||
|
||
from pygc import great_circle | ||
|
||
|
||
class GreatCircleTest(unittest.TestCase): | ||
def test_great_circle_scalars(): | ||
# One decimal degree is 111000m | ||
latitude = 40.0 | ||
longitude = -76.0 | ||
|
||
def test_great_circle_scalars(self): | ||
# One decimal degree is 111000m | ||
latitude = 40.0 | ||
longitude = -76.0 | ||
azimuth = 90 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone to the right | ||
assert new_gc["longitude"] > longitude + 0.9 | ||
|
||
azimuth = 90 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone to the right | ||
assert new_gc["longitude"] > longitude + 0.9 | ||
azimuth = 270 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone to the left | ||
assert new_gc["longitude"] < longitude - 0.9 | ||
|
||
azimuth = 270 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone to the left | ||
assert new_gc["longitude"] < longitude - 0.9 | ||
azimuth = 180 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone down | ||
assert new_gc["latitude"] < latitude - 0.9 | ||
|
||
azimuth = 180 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone down | ||
assert new_gc["latitude"] < latitude - 0.9 | ||
azimuth = 0 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone up | ||
assert new_gc["latitude"] > latitude + 0.9 | ||
|
||
azimuth = 0 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone up | ||
assert new_gc["latitude"] > latitude + 0.9 | ||
azimuth = 315 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone up and to the left | ||
assert new_gc["latitude"] > latitude + 0.45 | ||
assert new_gc["longitude"] < longitude - 0.45 | ||
|
||
azimuth = 315 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone up and to the left | ||
assert new_gc["latitude"] > latitude + 0.45 | ||
assert new_gc["longitude"] < longitude - 0.45 | ||
|
||
def test_great_circle_numpy(self): | ||
# One decimal degree is 111000m | ||
latitude = np.asarray([40.0, 50.0, 60.0]) | ||
longitude = np.asarray([-76.0, -86.0, -96.0]) | ||
def test_great_circle_numpy(): | ||
# One decimal degree is 111000m | ||
latitude = np.asarray([40.0, 50.0, 60.0]) | ||
longitude = np.asarray([-76.0, -86.0, -96.0]) | ||
|
||
azimuth = 90 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone to the right | ||
assert (new_gc["longitude"] > longitude + 0.9).all() | ||
azimuth = 90 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone to the right | ||
assert (new_gc["longitude"] > longitude + 0.9).all() | ||
|
||
azimuth = 270 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone to the left | ||
assert (new_gc["longitude"] < longitude - 0.9).all() | ||
azimuth = 270 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone to the left | ||
assert (new_gc["longitude"] < longitude - 0.9).all() | ||
|
||
azimuth = 180 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone down | ||
assert (new_gc["latitude"] < latitude - 0.9).all() | ||
azimuth = 180 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone down | ||
assert (new_gc["latitude"] < latitude - 0.9).all() | ||
|
||
azimuth = 0 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone up | ||
assert (new_gc["latitude"] > latitude + 0.9).all() | ||
azimuth = 0 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone up | ||
assert (new_gc["latitude"] > latitude + 0.9).all() | ||
|
||
azimuth = 315 | ||
new_gc = great_circle(distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude) | ||
# We should have gone up and to the left | ||
assert (new_gc["latitude"] > latitude + 0.45).all() | ||
assert (new_gc["longitude"] < longitude - 0.45).all() | ||
azimuth = 315 | ||
new_gc = great_circle( | ||
distance=111000, azimuth=azimuth, latitude=latitude, longitude=longitude | ||
) | ||
# We should have gone up and to the left | ||
assert (new_gc["latitude"] > latitude + 0.45).all() | ||
assert (new_gc["longitude"] < longitude - 0.45).all() |
Oops, something went wrong.