MCPcopy
hub / github.com/MaartenGr/BERTopic / test_get_representative_docs

Function test_get_representative_docs

tests/test_representation/test_get.py:85–100  ·  view source on GitHub ↗
(model, request)

Source from the content-addressed store, hash-verified

83 ],
84)
85def test_get_representative_docs(model, request):
86 topic_model = copy.deepcopy(request.getfixturevalue(model))
87 all_docs = topic_model.get_representative_docs()
88 unique_topics = set(topic_model.topics_)
89 topics_in_mapper = set(np.array(topic_model.topic_mapper_.mappings_)[:, -1])
90
91 assert len(all_docs) == len(topic_model.topic_sizes_.keys())
92 assert len(all_docs) == len(topics_in_mapper)
93 assert len(all_docs) == topic_model.c_tf_idf_.shape[0]
94 assert len(all_docs) == len(topic_model.topic_labels_)
95 assert all([True if len(docs) == 3 else False for docs in all_docs.values()])
96
97 topics = set(list(all_docs.keys()))
98
99 assert len(topics.difference(unique_topics)) == 0
100 assert len(topics.difference(topics_in_mapper)) == 0
101
102
103@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected