[test] Add test for GeographicalProcessing
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 24 Jun 2014 23:02:40 +0000
changeset 450 28ba90f7f947
parent 449 80c0a2d8624a
child 451 db82a2d5cf88
[test] Add test for GeographicalProcessing
test/test_distances.py
--- a/test/test_distances.py	Tue Jun 24 21:10:26 2014 +0000
+++ b/test/test_distances.py	Tue Jun 24 23:02:40 2014 +0000
@@ -28,7 +28,7 @@
 from nazca.utils.distances import (levenshtein, soundex, soundexcode,
                                    difflib_match,
                                    jaccard, euclidean, geographical,
-                                   ExactMatchProcessing,
+                                   ExactMatchProcessing, GeographicalProcessing,
                                    LevenshteinProcessing, SoundexProcessing,
                                    JaccardProcessing, DifflibProcessing, TemporalProcessing)
 
@@ -133,8 +133,16 @@
         paris = (48.856578, 2.351828)
         london = (51.504872, -0.07857)
         dist_parislondon = geographical(paris, london, in_radians=False)
+        self.assertAlmostEqual(dist_parislondon, 341564, 0)
 
-        self.assertAlmostEqual(dist_parislondon, 341564, 0)
+
+class GeographicalTestCase(unittest.TestCase):
+
+    def test_geographical(self):
+        processing = GeographicalProcessing(units='km')
+        _input = ((48.856578, 2.351828), (51.504872, -0.07857))
+        pdist = processing.pdist(_input)
+        self.assertEqual([341.56415945105], pdist)
 
 
 class ExactMatchTestCase(unittest.TestCase):