public void ComputeHashTest() { var perms = new TestPermutations(); var minHashService = new MinHashService(perms); byte[] hashed = minHashService.Hash(new TinyFingerprintSchema(10).SetTrueAt(2, 4, 6), perms.GetPermutations().Length); Assert.AreEqual(1, hashed[0]); Assert.AreEqual(0, hashed[1]); Assert.AreEqual(255, hashed[2]); }
public void ShouldNotIdentifyTooManyHashesOnLastPosition() { var random = new Random(1); var permutations = new MaxEntropyPermutations(); var minHash = new MinHashService(permutations); var counts = new List <int>(); int maxIndex = permutations.GetPermutations().First().Length; Assert.AreEqual(255, maxIndex); for (int i = 0; i < 50000; ++i) { var schema = TestUtilities.GenerateRandomFingerprint(random, 200, 128, 32); byte[] hashes = minHash.Hash(schema, 25 * 4); int count = hashes.Count(last => last == maxIndex); counts.Add(count); } Console.WriteLine($"Avg. Permutations {counts.Average():0.000}"); Console.WriteLine($"Max. {counts.Max()}"); Console.WriteLine($"Min. {counts.Min()}"); Assert.IsTrue(counts.Average() <= 0.25, "On average we expect no more than 0.25 elements in the schema to contain hashes at last position"); }
public void DependencyResolverTest() { var instance = new MinHashService(); Assert.IsNotNull(instance); }
public void SetUp() { permutations = new Mock <IPermutations>(MockBehavior.Strict); minHashService = new MinHashService(permutations.Object); }
public void SetUp() { permutations = new Mock <IPermutations>(MockBehavior.Strict); DependencyResolver.Current.Bind <IPermutations, IPermutations>(permutations.Object); minHashService = new MinHashService(); }