Download tests/test_vectorizer.py from devrup404/SignalMod: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/devrup404/SignalMod/resolve/ea0e222c0833664ace2bb85032dded1080fffa70/tests/test_vectorizer.py
- Command line
-
hf download hf://spaces/devrup404/SignalMod@ea0e222c0833664ace2bb85032dded1080fffa70/tests/test_vectorizer.py
-
curl -L -o test_vectorizer.py https://huggingface.co/spaces/devrup404/SignalMod/resolve/ea0e222c0833664ace2bb85032dded1080fffa70/tests/test_vectorizer.py
1.05 kB
| """Tests del vectorizador TF-IDF.""" | |
| import pytest | |
| from src.features.vectorizer import Vectorizer | |
| # min_df=3 en configs/features.yaml: términos deben aparecer en ≥3 documentos | |
| CORPUS_TRAIN = [ | |
| "the quick brown fox jumps", | |
| "the lazy dog runs fast", | |
| "the fox and dog play together", | |
| "another quick fox story here", | |
| ] | |
| CORPUS_TEST = ["the fox is quick today"] | |
| def vectorizer(features_config: str) -> Vectorizer: | |
| return Vectorizer(config_path=features_config, method="tfidf") | |
| def test_fit_transform_output_shape(vectorizer: Vectorizer): | |
| matrix = vectorizer.fit_transform(CORPUS_TRAIN) | |
| assert matrix.shape[0] == len(CORPUS_TRAIN) | |
| assert matrix.shape[1] > 0 | |
| assert matrix.shape[1] <= 5000 | |
| def test_transform_preserves_sample_count(vectorizer: Vectorizer): | |
| train_matrix = vectorizer.fit_transform(CORPUS_TRAIN) | |
| test_matrix = vectorizer.transform(CORPUS_TEST) | |
| assert test_matrix.shape[0] == len(CORPUS_TEST) | |
| assert test_matrix.shape[1] == train_matrix.shape[1] | |