-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62c7cb6
commit 00af3c6
Showing
3 changed files
with
86 additions
and
72 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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
python -m doctest -o IGNORE_EXCEPTION_DETAIL -f test/test.txt | ||
python3.8 -m venv venv | ||
|
||
[ $? -eq 0 ] && echo 'Test passed.' | ||
source venv/bin/activate | ||
|
||
python -m pip install -U pip setuptools | ||
python -m pip install -r requirements.txt | ||
|
||
python -m doctest -o IGNORE_EXCEPTION_DETAIL -f tests/tests.txt || exit 1 |
This file was deleted.
Oops, something went wrong.
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,78 @@ | ||
# doctest file for gpx_interpolate.py | ||
>>> import numpy as np | ||
>>> from gpx_interpolate import gpx_interpolate, gpx_calculate_distance, gpx_calculate_speed, gpx_remove_duplicates | ||
|
||
>>> test_data = {'lat': [0.0, 1.1, 1.1], 'lon': [0.0, 1.1, 1.1], 'ele': None, 'tstamp': [0.0, 1.1, 1.1], 'tzinfo': None} | ||
>>> empty_data = {'lat': [], 'lon': [], 'ele': None, 'tstamp': None, 'tzinfo': None} | ||
>>> DIST, TIME, RES, NUM = 172973.4, 1.1, 10.0, 10 | ||
|
||
## test gpx_interpolate | ||
>>> gpx_interpolate(empty_data) == gpx_interpolate(empty_data, res=RES) == gpx_interpolate(empty_data, num=NUM) == empty_data | ||
True | ||
|
||
>>> gpx_interpolate(test_data, res=0.0) | ||
Traceback (most recent call last): | ||
... | ||
OverflowError: ... | ||
|
||
>>> gpx_interpolate(test_data, res=-1.0) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: ... | ||
|
||
>>> gpx_interpolate(test_data, num=-1) | ||
Traceback (most recent call last): | ||
... | ||
ValueError: ... | ||
|
||
>>> test_data_interp = gpx_interpolate(test_data, res=RES) | ||
|
||
>>> len(test_data_interp['lat']) == len(test_data_interp['lon']) == len(test_data_interp['tstamp']) == int(np.ceil(DIST/RES)) | ||
True | ||
|
||
>>> test_data_interp = gpx_interpolate(test_data, num=NUM) | ||
|
||
>>> len(test_data_interp['lat']) == len(test_data_interp['lon']) == len(test_data_interp['tstamp']) == NUM | ||
True | ||
|
||
>>> abs(test_data_interp['lat'][0]-test_data['lat'][0]) < 1e-6 | ||
True | ||
|
||
>>> abs(test_data_interp['lat'][-1]-test_data['lat'][-1]) < 1e-6 | ||
True | ||
|
||
>>> abs(test_data_interp['lon'][0]-test_data['lon'][0]) < 1e-6 | ||
True | ||
|
||
>>> abs(test_data_interp['lon'][-1]-test_data['lon'][-1]) < 1e-6 | ||
True | ||
|
||
## test gpx_calculate_distance | ||
>>> test_dist = gpx_calculate_distance(test_data) | ||
|
||
>>> len(test_dist) == 3 | ||
True | ||
|
||
>>> test_dist[0] == test_dist[2] == 0.0 | ||
True | ||
|
||
>>> np.round(test_dist[1], decimals=1) == DIST | ||
True | ||
|
||
## test gpx_calculate_speed | ||
>>> test_speed = gpx_calculate_speed(test_data) | ||
|
||
>>> len(test_speed) == 3 | ||
True | ||
|
||
>>> test_speed[0] == test_speed[2] == 0.0 | ||
True | ||
|
||
>>> np.round(test_speed[1], decimals=1) == np.round(DIST/TIME, decimals=1) | ||
True | ||
|
||
## test gpx_remove_duplicates | ||
>>> test_data = gpx_remove_duplicates(test_data) | ||
|
||
>>> len(test_data['lat']) == len(test_data['lon']) == len(test_data['tstamp']) == 2 | ||
True |