def test_collisions(self): """Ensure that no pair of paths intersects.""" # collided_paths = list() paths = list() for p, w in self.word_cloud: paths.extend(BoxifyWord.cleaned_textpath(p)) for p1, p2 in combinations(paths, 2): if( p1.get_extents().overlaps(p2.get_extents()) and p1.intersects_path(p2, filled=True) ): # collided_paths.extend((p1, p2)) self.fail("Found a collision between two paths with holes")
def test_collisions_noloops(self): """Ensure that no pair of paths without holes intersects.""" words = [ "sun", "luck" ] * 50 weights = map( lambda w: 1.0/(w+1), range(100) ) word_weights = zip(words, weights) word_cloud = WordCloud(word_weights, seed=1) paths = list() for p, w in word_cloud: paths.extend(BoxifyWord.cleaned_textpath(p)) for p1, p2 in combinations(paths, 2): if( p1.get_extents().overlaps(p2.get_extents()) and p1.intersects_path(p2, filled=True) ): self.fail("Found a collision between two paths without holes")