Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def templateCfEntryValueDistance(self, cluster1, cluster2, value, tolerance, type_measurment):
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
distance = entry1.get_distance(entry2, type_measurment);
assert ( (value - tolerance < distance) and (value + tolerance > distance) );
def templateCfEntryValueDistance(self, cluster1, cluster2, value, tolerance, type_measurment):
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
distance = entry1.get_distance(entry2, type_measurment);
assert ( (value - tolerance < distance) and (value + tolerance > distance) );
def testCfEntryIncrease(self):
tolerance = 0.00001;
cluster = [ [0.1, 0.1], [0.2, 0.2], [0.5, 0.5], [0.4, 0.4], [0.6, 0.6] ];
entry1 = cfentry(len(cluster), linear_sum(cluster), square_sum(cluster));
entry2 = entry1 + entry1;
assert cfentry(10, [3.6, 3.6], 3.28) == entry2;
entry2 = entry2 + entry2;
assert cfentry(20, [7.2, 7.2], 6.56) == entry2;
def templateCfEntryDistance(self, type_measurement):
cluster1 = [[0.1, 0.1], [0.1, 0.2], [0.2, 0.1], [0.2, 0.2]];
cluster2 = [[0.4, 0.4], [0.4, 0.5], [0.5, 0.4], [0.5, 0.5]];
cluster3 = [[0.9, 0.9], [0.9, 1.0], [1.0, 0.9], [1.0, 1.0]];
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
entry3 = cfentry(len(cluster3), linear_sum(cluster3), square_sum(cluster3));
distance12 = entry1.get_distance(entry2, type_measurement);
distance23 = entry2.get_distance(entry3, type_measurement);
distance13 = entry1.get_distance(entry3, type_measurement);
assert distance12 < distance23;
assert distance23 < distance13;
def templateCfEntryDistance(self, type_measurement):
cluster1 = [[0.1, 0.1], [0.1, 0.2], [0.2, 0.1], [0.2, 0.2]];
cluster2 = [[0.4, 0.4], [0.4, 0.5], [0.5, 0.4], [0.5, 0.5]];
cluster3 = [[0.9, 0.9], [0.9, 1.0], [1.0, 0.9], [1.0, 1.0]];
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
entry3 = cfentry(len(cluster3), linear_sum(cluster3), square_sum(cluster3));
distance12 = entry1.get_distance(entry2, type_measurement);
distance23 = entry2.get_distance(entry3, type_measurement);
distance13 = entry1.get_distance(entry3, type_measurement);
assert distance12 < distance23;
assert distance23 < distance13;
def testCfTreeInserionOneLeafThreeEntries(self):
cluster1 = [[0.1, 0.1], [0.1, 0.2], [0.2, 0.1], [0.2, 0.2]];
cluster2 = [[0.4, 0.4], [0.4, 0.5], [0.5, 0.4], [0.5, 0.5]];
cluster3 = [[0.9, 0.9], [0.9, 1.0], [1.0, 0.9], [1.0, 1.0]];
tree = cftree(3, 4, 0.0);
tree.insert_cluster(cluster1);
tree.insert_cluster(cluster2);
tree.insert_cluster(cluster3);
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
entry3 = cfentry(len(cluster3), linear_sum(cluster3), square_sum(cluster3));
assert tree.find_nearest_leaf(entry1) == tree.find_nearest_leaf(entry2);
assert tree.find_nearest_leaf(entry2) == tree.find_nearest_leaf(entry3);
def templateCfEntryDistance(self, type_measurement):
cluster1 = [[0.1, 0.1], [0.1, 0.2], [0.2, 0.1], [0.2, 0.2]];
cluster2 = [[0.4, 0.4], [0.4, 0.5], [0.5, 0.4], [0.5, 0.5]];
cluster3 = [[0.9, 0.9], [0.9, 1.0], [1.0, 0.9], [1.0, 1.0]];
entry1 = cfentry(len(cluster1), linear_sum(cluster1), square_sum(cluster1));
entry2 = cfentry(len(cluster2), linear_sum(cluster2), square_sum(cluster2));
entry3 = cfentry(len(cluster3), linear_sum(cluster3), square_sum(cluster3));
distance12 = entry1.get_distance(entry2, type_measurement);
distance23 = entry2.get_distance(entry3, type_measurement);
distance13 = entry1.get_distance(entry3, type_measurement);
assert distance12 < distance23;
assert distance23 < distance13;