Extend tagger and senter tests

So that they, like the other tests, also check that we get no
activations if no activations were requested.
This commit is contained in:
Daniël de Kok 2022-06-24 10:18:00 +02:00
parent 009a96085b
commit c8a12c5d85
2 changed files with 8 additions and 1 deletions

View File

@ -115,12 +115,16 @@ def test_store_activations():
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
nlp.initialize(get_examples=lambda: train_examples)
nO = senter.model.get_dim("nO")
doc = nlp("This is a test.")
assert len(list(doc.activations["senter"].keys())) == 0
senter.store_activations = True
doc = nlp("This is a test.")
assert "senter" in doc.activations
assert set(doc.activations["senter"].keys()) == {"guesses", "probs"}
assert doc.activations["senter"]["probs"].shape == (5, 2)
assert doc.activations["senter"]["probs"].shape == (5, nO)
assert doc.activations["senter"]["guesses"].shape == (5,)
senter.store_activations = ["probs"]

View File

@ -222,6 +222,9 @@ def test_store_activations():
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
nlp.initialize(get_examples=lambda: train_examples)
doc = nlp("This is a test.")
assert len(list(doc.activations["tagger"].keys())) == 0
tagger.store_activations = True
doc = nlp("This is a test.")
assert "tagger" in doc.activations