MCPcopy
hub / github.com/explosion/spaCy / test_language_source_and_vectors

Function test_language_source_and_vectors

spacy/tests/test_language.py:706–723  ·  view source on GitHub ↗
(nlp2)

Source from the content-addressed store, hash-verified

704
705
706def 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])

Callers

nothing calls this directly

Calls 6

add_pipeMethod · 0.95
initializeMethod · 0.95
LanguageClass · 0.90
add_labelMethod · 0.45
addMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…