def test_jaccard_indexes_of_crossing_quadrangles(self): first_quadrangle = self.first_quadrangle second_quadrangle = self.second_quadrangle third_quadrangle = self.third_quadrangle fourth_quadrangle = self.fourth_quadrangle fifth_quadrangle = self.fifth_quadrangle index = RTreeConvexQuadrangleIndex(( first_quadrangle, second_quadrangle, third_quadrangle, fourth_quadrangle, fifth_quadrangle, )) self.assertEqual( { first_quadrangle: ((first_quadrangle.area / 2) / (first_quadrangle.area / 2 + fifth_quadrangle.area)), third_quadrangle: third_quadrangle.area / fifth_quadrangle.area, fourth_quadrangle: fifth_quadrangle.area / fourth_quadrangle.area, fifth_quadrangle: 1.0, }, index.jaccard_indexes(fifth_quadrangle))
def test_clear(self): first_quadrangle = self.first_quadrangle second_quadrangle = self.second_quadrangle fourth_quadrangle = self.fourth_quadrangle index = RTreeConvexQuadrangleIndex( (first_quadrangle, second_quadrangle)) index.clear() self.assertEqual(0, len(index)) self.assertEqual({}, index.jaccard_indexes(fourth_quadrangle))
def test_discard(self): first_quadrangle = self.first_quadrangle fourth_quadrangle = self.fourth_quadrangle index = RTreeConvexQuadrangleIndex( (first_quadrangle, self.second_quadrangle)) index.discard(self.second_quadrangle) self.assertEqual(1, len(index)) self.assertEqual({first_quadrangle}, set(index.quadrangles)) self.assertEqual( { first_quadrangle: first_quadrangle.area / fourth_quadrangle.area, }, index.jaccard_indexes(fourth_quadrangle), )
def test_discard_duplicate(self): first_quadrangle = self.first_quadrangle second_quadrangle = self.second_quadrangle fourth_quadrangle = self.fourth_quadrangle index = RTreeConvexQuadrangleIndex( (first_quadrangle, second_quadrangle)) index.discard( GEOSConvexQuadrangle( top_left=second_quadrangle.top_left, top_right=second_quadrangle.top_right, bottom_left=second_quadrangle.bottom_left, bottom_right=second_quadrangle.bottom_right, )) self.assertEqual(1, len(index)) self.assertEqual({first_quadrangle}, set(index.quadrangles)) self.assertEqual( { first_quadrangle: first_quadrangle.area / fourth_quadrangle.area, }, index.jaccard_indexes(fourth_quadrangle), )
def test_jaccard_indexes_of_touching_quadrangles(self): first_quadrangle = self.first_quadrangle third_quadrangle = self.third_quadrangle index = RTreeConvexQuadrangleIndex((first_quadrangle, )) self.assertEqual({}, index.jaccard_indexes(third_quadrangle))
def test_jaccard_indexes_of_disjoint_quadrangles(self): first_quadrangle = self.first_quadrangle second_quadrangle = self.second_quadrangle index = RTreeConvexQuadrangleIndex((first_quadrangle, )) self.assertEqual({}, index.jaccard_indexes(second_quadrangle))