MCPcopy Create free account
hub / github.com/modAL-python/modAL / TestDensity

Class TestDensity

tests/core_tests.py:386–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384
385
386class TestDensity(unittest.TestCase):
387
388 def test_similarize_distance(self):
389 from scipy.spatial.distance import cosine
390 sim = modAL.density.similarize_distance(cosine)
391 for _ in range(100):
392 for n_dim in range(1, 10):
393 X_1, X_2 = np.random.rand(n_dim), np.random.rand(n_dim)
394 np.testing.assert_almost_equal(
395 sim(X_1, X_2),
396 1/(1 + cosine(X_1, X_2))
397 )
398
399 def test_information_density(self):
400 for n_samples in range(1, 10):
401 for n_dim in range(1, 10):
402 X_pool = np.random.rand(n_samples, n_dim)
403 similarities = modAL.density.information_density(X_pool)
404 np.testing.assert_equal(len(similarities), n_samples)
405
406
407class TestDisagreements(unittest.TestCase):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…