| 704 | |
| 705 | |
| 706 | def test_language_source_and_vectors(nlp2): |
| 707 | nlp = Language(Vocab()) |
| 708 | textcat = nlp.add_pipe("textcat") |
| 709 | for label in ("POSITIVE", "NEGATIVE"): |
| 710 | textcat.add_label(label) |
| 711 | nlp.initialize() |
| 712 | long_string = "thisisalongstring" |
| 713 | assert long_string not in nlp.vocab.strings |
| 714 | assert long_string not in nlp2.vocab.strings |
| 715 | nlp.vocab.strings.add(long_string) |
| 716 | assert nlp.vocab.vectors.to_bytes() != nlp2.vocab.vectors.to_bytes() |
| 717 | vectors_bytes = nlp.vocab.vectors.to_bytes() |
| 718 | with pytest.warns(UserWarning): |
| 719 | nlp2.add_pipe("textcat", name="textcat2", source=nlp) |
| 720 | # strings should be added |
| 721 | assert long_string in nlp2.vocab.strings |
| 722 | # vectors should remain unmodified |
| 723 | assert nlp.vocab.vectors.to_bytes() == vectors_bytes |
| 724 | |
| 725 | |
| 726 | @pytest.mark.parametrize("n_process", [1, 2]) |