Skip to content

Commit 08d114d

Browse files
authored
Merge pull request #190 from InsightLab/examples
Putting examples on geoutils module
2 parents cb16403 + c5f4b42 commit 08d114d

File tree

5 files changed

+292
-150
lines changed

5 files changed

+292
-150
lines changed

pymove/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
from .utils import (
2020
constants,
2121
conversions,
22+
data_augmentation,
2223
datetime,
2324
distances,
25+
geoutils,
2426
integration,
27+
log,
2528
math,
2629
mem,
2730
trajectories,

pymove/tests/test_utils_geoutils.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import os
2-
3-
import matplotlib.pyplot as plt
41
import numpy as np
5-
from matplotlib.testing.compare import compare_images
62
from numpy.testing import assert_array_equal, assert_equal
73
from pandas import DataFrame
84
from pandas.testing import assert_frame_equal
@@ -30,75 +26,6 @@ def test_v_color():
3026
assert_equal(expected_2, geoutils.v_color(line_2))
3127

3228

33-
def test_plot_coords(tmpdir):
34-
d = tmpdir.mkdir('preprocessing')
35-
36-
file_write_default = d.join('plot_coords.png')
37-
38-
filename_write_default = os.path.join(
39-
file_write_default.dirname, file_write_default.basename
40-
)
41-
42-
coords = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
43-
44-
fig, ax = plt.subplots(figsize=(21, 9))
45-
geoutils.plot_coords(ax, coords)
46-
plt.savefig(filename_write_default, dpi=100)
47-
48-
test_dir = os.path.abspath(os.path.dirname(__file__))
49-
data_dir = os.path.join(test_dir, 'baseline/plot_coords.png')
50-
51-
compare_images(
52-
data_dir, filename_write_default, 0.0001, in_decorator=False
53-
)
54-
55-
56-
def test_plot_bounds(tmpdir):
57-
d = tmpdir.mkdir('preprocessing')
58-
59-
file_write_default = d.join('plot_bounds.png')
60-
61-
filename_write_default = os.path.join(
62-
file_write_default.dirname, file_write_default.basename
63-
)
64-
65-
bounds = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
66-
67-
fig, ax = plt.subplots(figsize=(21, 9))
68-
geoutils.plot_bounds(ax, bounds)
69-
plt.savefig(filename_write_default, dpi=100)
70-
71-
test_dir = os.path.abspath(os.path.dirname(__file__))
72-
data_dir = os.path.join(test_dir, 'baseline/plot_bounds.png')
73-
74-
compare_images(
75-
data_dir, filename_write_default, 0.0001, in_decorator=False
76-
)
77-
78-
79-
def test_plot_line(tmpdir):
80-
d = tmpdir.mkdir('preprocessing')
81-
82-
file_write_default = d.join('plot_line.png')
83-
84-
filename_write_default = os.path.join(
85-
file_write_default.dirname, file_write_default.basename
86-
)
87-
88-
line = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
89-
90-
fig, ax = plt.subplots(figsize=(21, 9))
91-
geoutils.plot_line(ax, line)
92-
plt.savefig(filename_write_default, dpi=100)
93-
94-
test_dir = os.path.abspath(os.path.dirname(__file__))
95-
data_dir = os.path.join(test_dir, 'baseline/plot_line.png')
96-
97-
compare_images(
98-
data_dir, filename_write_default, 0.0001, in_decorator=False
99-
)
100-
101-
10229
def test_encode():
10330
lat1, lon1 = -3.777736, -38.547792
10431
lat2, lon2 = -3.793388, -38.517722

pymove/tests/test_visualization_matplotlib.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22

3+
import matplotlib.pyplot as plt
34
from matplotlib.testing.compare import compare_images
5+
from shapely.geometry import LineString
46

57
import pymove.visualization.matplotlib as mpl
68
from pymove import MoveDataFrame
@@ -156,3 +158,72 @@ def test_plot_trajectories(tmpdir):
156158
filename_write_default,
157159
0.0001,
158160
in_decorator=False)
161+
162+
163+
def test_plot_coords(tmpdir):
164+
d = tmpdir.mkdir('visualization')
165+
166+
file_write_default = d.join('plot_coords.png')
167+
168+
filename_write_default = os.path.join(
169+
file_write_default.dirname, file_write_default.basename
170+
)
171+
172+
coords = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
173+
174+
_, ax = plt.subplots(figsize=(21, 9))
175+
mpl.plot_coords(ax, coords)
176+
plt.savefig(filename_write_default, dpi=100)
177+
178+
test_dir = os.path.abspath(os.path.dirname(__file__))
179+
data_dir = os.path.join(test_dir, 'baseline/plot_coords.png')
180+
181+
compare_images(
182+
data_dir, filename_write_default, 0.0001, in_decorator=False
183+
)
184+
185+
186+
def test_plot_bounds(tmpdir):
187+
d = tmpdir.mkdir('visualization')
188+
189+
file_write_default = d.join('plot_bounds.png')
190+
191+
filename_write_default = os.path.join(
192+
file_write_default.dirname, file_write_default.basename
193+
)
194+
195+
bounds = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
196+
197+
_, ax = plt.subplots(figsize=(21, 9))
198+
mpl.plot_bounds(ax, bounds)
199+
plt.savefig(filename_write_default, dpi=100)
200+
201+
test_dir = os.path.abspath(os.path.dirname(__file__))
202+
data_dir = os.path.join(test_dir, 'baseline/plot_bounds.png')
203+
204+
compare_images(
205+
data_dir, filename_write_default, 0.0001, in_decorator=False
206+
)
207+
208+
209+
def test_plot_line(tmpdir):
210+
d = tmpdir.mkdir('visualization')
211+
212+
file_write_default = d.join('plot_line.png')
213+
214+
filename_write_default = os.path.join(
215+
file_write_default.dirname, file_write_default.basename
216+
)
217+
218+
line = LineString([(1, 1), (1, 2), (2, 2), (2, 3)])
219+
220+
_, ax = plt.subplots(figsize=(21, 9))
221+
mpl.plot_line(ax, line)
222+
plt.savefig(filename_write_default, dpi=100)
223+
224+
test_dir = os.path.abspath(os.path.dirname(__file__))
225+
data_dir = os.path.join(test_dir, 'baseline/plot_line.png')
226+
227+
compare_images(
228+
data_dir, filename_write_default, 0.0001, in_decorator=False
229+
)

0 commit comments

Comments
 (0)