MCPcopy Index your code
hub / github.com/clips/pattern / test_distancemap

Method test_distancemap

test/test_vector.py:746–754  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

744 print "pattern.vector.distance()"
745
746 def test_distancemap(self):
747 # Assert distance caching mechanism.
748 v1 = vector.Vector({"cat":1})
749 v2 = vector.Vector({"cat":0.5, "dog":1})
750 m = vector.DistanceMap(method=vector.COSINE)
751 for i in range(100):
752 self.assertAlmostEqual(m.distance(v1, v2), 0.55, places=2)
753 self.assertAlmostEqual(m._cache[(v1.id, v2.id)], 0.55, places=2)
754 print "pattern.vector.DistanceMap"
755
756 def _test_k_means(self, seed):
757 # Assert k-means clustering accuracy.

Callers

nothing calls this directly

Calls 1

distanceMethod · 0.95

Tested by

no test coverage detected