Download BERTopic/tests/test_variations/test_dynamic.py from kisejin/TopicModelingRepo: direct link, hf CLI and curl.
- Browser
- Download file 645 Bytes
-
https://huggingface.co/kisejin/TopicModelingRepo/resolve/5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_variations/test_dynamic.py
- Command line
-
hf download hf://kisejin/TopicModelingRepo@5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_variations/test_dynamic.py
-
curl -L -o test_dynamic.py https://huggingface.co/kisejin/TopicModelingRepo/resolve/5ecdc19ebac471cb51415c4e2fa755d81931c0ee/BERTopic/tests/test_variations/test_dynamic.py
645 Bytes
| import copy | |
| import pytest | |
| def test_dynamic(model, documents, request): | |
| topic_model = copy.deepcopy(request.getfixturevalue(model)) | |
| timestamps = [i % 10 for i in range(len(documents))] | |
| topics_over_time = topic_model.topics_over_time(documents, timestamps) | |
| assert topics_over_time.Frequency.sum() == len(documents) | |
| assert set(topics_over_time.Topic.unique()) == set(topic_model.topics_) | |
| assert len(topics_over_time.Timestamp.unique()) == len(set(timestamps)) | |