Skip to content
Snippets Groups Projects
Commit 9487015c authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

Merge branch '28-links-can-be-black' into 'develop'

Resolve "Links can be black"

Closes #28

See merge request !23
parents af54ffde 02a39530
No related branches found
No related tags found
2 merge requests!23Resolve "Links can be black",!13Draft: Develop
...@@ -153,7 +153,8 @@ def generate_points_with_features(data, positions, features_vectors, bounds, nod ...@@ -153,7 +153,8 @@ def generate_points_with_features(data, positions, features_vectors, bounds, nod
@jit(nopython=True) @jit(nopython=True)
def generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon, values, interpolate=False): def generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon, values,
link_type=None):
lon, lat = positions[0, 0], positions[0, 1] lon, lat = positions[0, 0], positions[0, 1]
current_value = values[0] current_value = values[0]
...@@ -164,19 +165,24 @@ def generate_links(data, positions, height, width, lower_lat, upper_lat, lower_l ...@@ -164,19 +165,24 @@ def generate_links(data, positions, height, width, lower_lat, upper_lat, lower_l
x_nxt, y_nxt = get_coord(latitude, longitude, height, width, lower_lat, upper_lat, lower_lon, x_nxt, y_nxt = get_coord(latitude, longitude, height, width, lower_lat, upper_lat, lower_lon,
upper_lon) upper_lon)
lon, lat = longitude, latitude lon, lat = longitude, latitude
if interpolate and (nxt_value != current_value).all() and (x_prv != x_nxt) and (y_prev!= y_nxt):
dist = dist_on_grid(x_prv, y_prev, x_nxt, y_nxt) dist = dist_on_grid(x_prv, y_prev, x_nxt, y_nxt)
for x, y in bresenham(x_prv, y_prev, x_nxt, y_nxt): for x, y in bresenham(x_prv, y_prev, x_nxt, y_nxt):
dist_prev = dist_on_grid(x_prv, y_prev, x, y) dist_prev = dist_on_grid(x_prv, y_prev, x, y)
dist_next = dist_on_grid(x, y, x_nxt, y_nxt) dist_next = dist_on_grid(x, y, x_nxt, y_nxt)
pixel_color = current_value * (1-dist_prev/dist) + nxt_value * (1-dist_next/dist) pixel_color = current_value * (1 - dist_prev / dist) + nxt_value * (1 - dist_next / dist)
for i in range(len(pixel_color)): for i in range(len(pixel_color)):
if nxt_value[i] == current_value[i]:
data[x, y, i] = current_value[i]
elif link_type == 'interpolate':
data[x, y, i] = pixel_color[i] data[x, y, i] = pixel_color[i]
else: elif link_type == 'previous':
for x, y in bresenham(x_prv, y_prev, x_nxt, y_nxt):
for i in range(len(current_value)):
data[x, y, i] = current_value[i] data[x, y, i] = current_value[i]
elif link_type == 'next':
data[x, y, i] = nxt_value[i]
elif link_type == 'solid':
data[x, y, i] = 1
current_value = nxt_value current_value = nxt_value
...@@ -358,8 +364,8 @@ class AISTrajectory(AISPoints): ...@@ -358,8 +364,8 @@ class AISTrajectory(AISPoints):
result.append((row['ts_sec'], current_label)) result.append((row['ts_sec'], current_label))
return result return result
def generate_array_from_positions(self, height=256, width=256, link=True, bounding_box='fit', ref_index=-1, def generate_array_from_positions(self, height=256, width=256, link=None, bounding_box='fit', ref_index=-1,
features=None, node_size=0, interpolation=False): features=None, node_size=0):
positions = self.df[['longitude', 'latitude']].to_numpy() positions = self.df[['longitude', 'latitude']].to_numpy()
...@@ -393,14 +399,15 @@ class AISTrajectory(AISPoints): ...@@ -393,14 +399,15 @@ class AISTrajectory(AISPoints):
generate_points(data, positions, height, width, node_size, lower_lat, upper_lat, lower_lon, upper_lon) generate_points(data, positions, height, width, node_size, lower_lat, upper_lat, lower_lon, upper_lon)
if link: if link is not None:
generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon, generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon,
np.ones((len(positions), 1))) np.ones((len(positions), 1)), link)
else: else:
generate_points_with_features(data, positions, features_vectors, np.array(bounds), node_size, height, width, generate_points_with_features(data, positions, features_vectors, np.array(bounds), node_size, height, width,
lower_lat, upper_lat, lower_lon, upper_lon) lower_lat, upper_lat, lower_lon, upper_lon)
if link: if link is not None:
generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon, generate_links(data, positions, height, width, lower_lat, upper_lat, lower_lon, upper_lon,
generate_values(features_vectors, bounds), interpolate=interpolation) generate_values(features_vectors, bounds), link)
return data return data
DISABLE_JIT: 1
\ No newline at end of file
import numba
import unittest import unittest
from skais.ais.ais_trajectory import * from skais.ais.ais_trajectory import *
...@@ -311,12 +312,12 @@ class TestAISTrajectory(unittest.TestCase): ...@@ -311,12 +312,12 @@ class TestAISTrajectory(unittest.TestCase):
def test_compute_trajectory(self): def test_compute_trajectory(self):
times = np.array([i for i in range(0, 3001, 600)] + [i for i in range(4001, 7001, 600)]) times = np.array([i for i in range(0, 3001, 600)] + [i for i in range(4001, 7001, 600)])
self.assertEqual(6, compute_trajectory.py_func(times, 800)) self.assertEqual(6, compute_trajectory(times, 800))
def test_compute_trajectory_empty(self): def test_compute_trajectory_empty(self):
times = np.array([]) times = np.array([])
self.assertEqual(0, compute_trajectory.py_func(times, 800)) self.assertEqual(0, compute_trajectory(times, 800))
def test_apply_func_on_window(self): def test_apply_func_on_window(self):
self.assertRaises(ValueError, apply_func_on_window, np.arange(10), 0, 0, 'not valid string') self.assertRaises(ValueError, apply_func_on_window, np.arange(10), 0, 0, 'not valid string')
...@@ -394,7 +395,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -394,7 +395,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
def test_generate_array_from_positions(self): def test_generate_array_from_positions(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit', result = self.trajectory.generate_array_from_positions(height=9, width=9, link=None, bounding_box='fit',
features=None, node_size=0).reshape((9, 9)) features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0],
...@@ -409,7 +410,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -409,7 +410,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
np.testing.assert_array_equal(result, expected) np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_node_size(self): def test_generate_array_from_positions_node_size(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit', result = self.trajectory.generate_array_from_positions(height=9, width=9, link=None, bounding_box='fit',
features=None, node_size=1).reshape((9, 9)) features=None, node_size=1).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 1, 1], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1],
...@@ -434,7 +435,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -434,7 +435,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='solid', bounding_box='fit',
features=None, node_size=0).reshape((9, 18)) features=None, node_size=0).reshape((9, 18))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
...@@ -510,7 +511,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -510,7 +511,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='previous', bounding_box='fit',
features="sog", node_size=0).reshape((9, 18)) features="sog", node_size=0).reshape((9, 18))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
...@@ -537,7 +538,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -537,7 +538,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='previous', bounding_box='fit',
features=['sog', 'cog'], node_size=0) features=['sog', 'cog'], node_size=0)
expected = np.array([[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], expected = np.array([[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0.5, 0.25]], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0.5, 0.25]],
...@@ -561,7 +562,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -561,7 +562,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
np.testing.assert_array_equal(result, expected) np.testing.assert_array_equal(result, expected)
def test_generate_array_centered(self): def test_generate_array_centered(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='centered', result = self.trajectory.generate_array_from_positions(height=9, width=9, link=None, bounding_box='centered',
features=None, node_size=0).reshape((9, 9)) features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0],
...@@ -576,7 +577,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -576,7 +577,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
np.testing.assert_array_equal(result, expected) np.testing.assert_array_equal(result, expected)
def test_generate_array_bounding_box(self): def test_generate_array_bounding_box(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, result = self.trajectory.generate_array_from_positions(height=9, width=9, link=None,
bounding_box=[(0, 0), (10, 10)], bounding_box=[(0, 0), (10, 10)],
features=None, node_size=0).reshape((9, 9)) features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1],
...@@ -603,7 +604,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -603,7 +604,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='previous', bounding_box='fit',
features={"sog": (0, 80)}, node_size=0).reshape((9, 18)) features={"sog": (0, 80)}, node_size=0).reshape((9, 18))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
...@@ -614,7 +615,8 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -614,7 +615,8 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
[0, 0, 0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0, 0, 0.5], [0, 0, 0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0, 0, 0.5],
[0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0.5], [0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0.5],
[0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.5]]) / 2 [0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.5]]) / 2
with np.printoptions(threshold=320):
print(result)
np.testing.assert_array_equal(result, expected) np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_with_line_multi_channel_dict(self): def test_generate_array_from_positions_with_line_multi_channel_dict(self):
...@@ -630,7 +632,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -630,7 +632,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='previous', bounding_box='fit',
features={'sog': (0, 40), 'cog': (0, 40)}, node_size=0) features={'sog': (0, 40), 'cog': (0, 40)}, node_size=0)
expected = np.array([[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], expected = np.array([[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0],
[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0.5, 0.25]], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0.5, 0.25]],
...@@ -665,10 +667,9 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -665,10 +667,9 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link='interpolate', bounding_box='fit',
features={"sog": (0, 80)}, node_size=0, features={"sog": (0, 80)}, node_size=0).reshape((9, 18))
interpolation='linear').reshape((9, 18))
print(result)
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5], expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.46875], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.46875],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4375], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4375],
......
...@@ -4,97 +4,97 @@ from skais.process.geography import * ...@@ -4,97 +4,97 @@ from skais.process.geography import *
class MyTestCase(unittest.TestCase): class MyTestCase(unittest.TestCase):
def test_to_rad_0(self): def test_to_rad_0(self):
result = to_rad.py_func(0) result = to_rad(0)
expected = 0 expected = 0
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_90(self): def test_to_rad_90(self):
result = to_rad.py_func(90) result = to_rad(90)
expected = np.pi / 2 expected = np.pi / 2
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_180(self): def test_to_rad_180(self):
result = to_rad.py_func(180) result = to_rad(180)
expected = np.pi expected = np.pi
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_360(self): def test_to_rad_360(self):
result = to_rad.py_func(360) result = to_rad(360)
expected = 2 * np.pi expected = 2 * np.pi
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_m180(self): def test_to_rad_m180(self):
result = to_rad.py_func(-180) result = to_rad(-180)
expected = -np.pi expected = -np.pi
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_m90(self): def test_to_rad_m90(self):
result = to_rad.py_func(-90) result = to_rad(-90)
expected = -np.pi / 2 expected = -np.pi / 2
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_270(self): def test_to_rad_270(self):
result = to_rad.py_func(270) result = to_rad(270)
expected = 3 * np.pi / 2 expected = 3 * np.pi / 2
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_rad_810(self): def test_to_rad_810(self):
result = to_rad.py_func(810) result = to_rad(810)
expected = 9 * np.pi / 2 expected = 9 * np.pi / 2
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_0(self): def test_to_deg_0(self):
result = to_deg.py_func(0) result = to_deg(0)
expected = 0 expected = 0
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_90(self): def test_to_deg_90(self):
result = to_deg.py_func(np.pi / 2) result = to_deg(np.pi / 2)
expected = 90 expected = 90
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_180(self): def test_to_deg_180(self):
result = to_deg.py_func(np.pi) result = to_deg(np.pi)
expected = 180 expected = 180
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_360(self): def test_to_deg_360(self):
result = to_deg.py_func(2 * np.pi) result = to_deg(2 * np.pi)
expected = 360 expected = 360
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_m180(self): def test_to_deg_m180(self):
result = to_deg.py_func(-np.pi) result = to_deg(-np.pi)
expected = -180 expected = -180
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_m90(self): def test_to_deg_m90(self):
result = to_deg.py_func(-np.pi / 2) result = to_deg(-np.pi / 2)
expected = -90 expected = -90
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_270(self): def test_to_deg_270(self):
result = to_deg.py_func(3 * np.pi / 2) result = to_deg(3 * np.pi / 2)
expected = 270 expected = 270
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
def test_to_deg_810(self): def test_to_deg_810(self):
result = to_deg.py_func(9 * np.pi / 2) result = to_deg(9 * np.pi / 2)
expected = 810 expected = 810
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
...@@ -103,7 +103,7 @@ class MyTestCase(unittest.TestCase): ...@@ -103,7 +103,7 @@ class MyTestCase(unittest.TestCase):
paris = (2.3522, 48.8566) paris = (2.3522, 48.8566)
marseille = (5.3698, 43.2965) marseille = (5.3698, 43.2965)
result = bearing.py_func(paris, marseille) result = bearing(paris, marseille)
expected = 158.2694 expected = 158.2694
self.assertAlmostEqual(result, expected, places=4) self.assertAlmostEqual(result, expected, places=4)
...@@ -112,7 +112,7 @@ class MyTestCase(unittest.TestCase): ...@@ -112,7 +112,7 @@ class MyTestCase(unittest.TestCase):
p1 = (0, 0) p1 = (0, 0)
p2 = (90, 0) p2 = (90, 0)
result = bearing.py_func(p1, p2) result = bearing(p1, p2)
expected = 90 expected = 90
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
...@@ -121,7 +121,7 @@ class MyTestCase(unittest.TestCase): ...@@ -121,7 +121,7 @@ class MyTestCase(unittest.TestCase):
p1 = (0, 0) p1 = (0, 0)
p2 = (0, 90) p2 = (0, 90)
result = bearing.py_func(p1, p2) result = bearing(p1, p2)
expected = 0 expected = 0
self.assertAlmostEqual(result, expected) self.assertAlmostEqual(result, expected)
...@@ -131,28 +131,28 @@ class MyTestCase(unittest.TestCase): ...@@ -131,28 +131,28 @@ class MyTestCase(unittest.TestCase):
p2 = (0, 0) p2 = (0, 0)
p3 = (10, 0) p3 = (10, 0)
self.assertAlmostEqual(90, angle_between_three_points.py_func(p1, p2, p3), places=3) self.assertAlmostEqual(90, angle_between_three_points(p1, p2, p3), places=3)
def test_angle_between_three_points_2(self): def test_angle_between_three_points_2(self):
p1 = (0, -10) p1 = (0, -10)
p2 = (0, 0) p2 = (0, 0)
p3 = (-10, 0) p3 = (-10, 0)
self.assertAlmostEqual(-90, angle_between_three_points.py_func(p1, p2, p3), places=3) self.assertAlmostEqual(-90, angle_between_three_points(p1, p2, p3), places=3)
def test_angle_between_three_points_3(self): def test_angle_between_three_points_3(self):
p1 = (0, -10) p1 = (0, -10)
p2 = (0, 0) p2 = (0, 0)
p3 = (10, 10) p3 = (10, 10)
self.assertAlmostEqual(180 - 44.56139, angle_between_three_points.py_func(p1, p2, p3), places=3) self.assertAlmostEqual(180 - 44.56139, angle_between_three_points(p1, p2, p3), places=3)
def test_angle_between_three_points_4(self): def test_angle_between_three_points_4(self):
p1 = (0, 0) p1 = (0, 0)
p2 = (0, 10) p2 = (0, 10)
p3 = (0, 0) p3 = (0, 0)
self.assertAlmostEqual(0, abs(angle_between_three_points.py_func(p1, p2, p3)), places=3) self.assertAlmostEqual(0, abs(angle_between_three_points(p1, p2, p3)), places=3)
def test_compute_point_angles(self): def test_compute_point_angles(self):
dat = np.array([(0, 0), (0, 10), (10, 10), (0, 10)]) dat = np.array([(0, 0), (0, 10), (10, 10), (0, 10)])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment