def test_generate_triples_factory(self): """Test generating a triples factory.""" for random_state in range(100): tf = generate_triples_factory( num_entities=self.num_entities, num_relations=self.num_relations, num_triples=self.num_triples, random_state=random_state, ) self.assertEqual(self.num_triples, tf.mapped_triples.shape[0]) self.assert_consecutive(get_entities(tf.mapped_triples)) self.assert_consecutive(get_relations(tf.mapped_triples))
def test_compacted(self): """Test that the results are compacted.""" for random_state in range(100): x = generate_triples( num_entities=self.num_entities, num_relations=self.num_relations, num_triples=self.num_triples, random_state=random_state, ) self.assertEqual(self.num_triples, x.shape[0]) self.assert_consecutive(get_entities(x)) self.assert_consecutive(get_relations(x))
def test_get_cover_deterministic(self): """Test _get_cover_deterministic.""" # generated_triples = generate_triples() cover = _get_cover_deterministic(triples=self.mapped_triples) # check type assert torch.is_tensor(cover) assert cover.dtype == torch.bool # check format assert cover.shape == (self.mapped_triples.shape[0],) # check coverage self.assertEqual( get_entities(self.mapped_triples), get_entities(self.mapped_triples[cover]), msg="entity coverage is not full", ) self.assertEqual( get_relations(self.mapped_triples), get_relations(self.mapped_triples[cover]), msg="relation coverage is not full", )