Fix redundant test. 2 failures

This commit is contained in:
Matthew Honnibal 2021-10-31 01:56:28 +02:00
parent 44b01d2a87
commit 385b669c5d

View File

@ -205,7 +205,7 @@ def test_train_empty():
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1])) train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
ner = nlp.add_pipe("ner", last=True) ner = nlp.add_pipe("ner", last=True)
ner.add_label("PERSON") ner.add_label("PERSON")
nlp.initialize() nlp.initialize(get_examples=lambda: train_examples)
for itn in range(2): for itn in range(2):
losses = {} losses = {}
batches = util.minibatch(train_examples, size=8) batches = util.minibatch(train_examples, size=8)
@ -301,11 +301,10 @@ def test_block_ner():
assert [token.ent_type_ for token in doc] == expected_types assert [token.ent_type_ for token in doc] == expected_types
@pytest.mark.parametrize("use_upper", [True, False]) def test_overfitting_IO():
def test_overfitting_IO(use_upper):
# Simple test to try and quickly overfit the NER component # Simple test to try and quickly overfit the NER component
nlp = English() nlp = English()
ner = nlp.add_pipe("ner", config={"model": {"use_upper": use_upper}}) ner = nlp.add_pipe("ner", config={"model": {}})
train_examples = [] train_examples = []
for text, annotations in TRAIN_DATA: for text, annotations in TRAIN_DATA:
train_examples.append(Example.from_dict(nlp.make_doc(text), annotations)) train_examples.append(Example.from_dict(nlp.make_doc(text), annotations))
@ -337,7 +336,6 @@ def test_overfitting_IO(use_upper):
assert ents2[0].label_ == "LOC" assert ents2[0].label_ == "LOC"
# Ensure that the predictions are still the same, even after adding a new label # Ensure that the predictions are still the same, even after adding a new label
ner2 = nlp2.get_pipe("ner") ner2 = nlp2.get_pipe("ner")
assert ner2.model.attrs["has_upper"] == use_upper
ner2.add_label("RANDOM_NEW_LABEL") ner2.add_label("RANDOM_NEW_LABEL")
doc3 = nlp2(test_text) doc3 = nlp2(test_text)
ents3 = doc3.ents ents3 = doc3.ents