Fix exclude and add test

This commit is contained in:
Ines Montani 2020-09-27 23:34:03 +02:00
parent c0c842ae5b
commit 9016d23cc5
2 changed files with 15 additions and 2 deletions

View File

@ -7,6 +7,7 @@ from spacy import util
from spacy import prefer_gpu, require_gpu
from spacy.ml._precomputable_affine import PrecomputableAffine
from spacy.ml._precomputable_affine import _backprop_precomputable_affine_padding
from thinc.api import Optimizer
@pytest.fixture
@ -157,3 +158,16 @@ def test_dot_to_dict(dot_notation, expected):
result = util.dot_to_dict(dot_notation)
assert result == expected
assert util.dict_to_dot(result) == dot_notation
def test_resolve_training_config():
config = {
"nlp": {"lang": "en", "disabled": []},
"training": {"dropout": 0.1, "optimizer": {"@optimizers": "Adam.v1"}},
"corpora": {},
}
resolved = util.resolve_training_config(config)
assert resolved["training"]["dropout"] == 0.1
assert isinstance(resolved["training"]["optimizer"], Optimizer)
assert resolved["corpora"] == {}
assert "nlp" not in resolved

View File

@ -416,10 +416,9 @@ def resolve_training_config(
RETURNS (Dict[str, Any]): The resolved config.
"""
config = config.copy()
excluded = {}
for key in exclude:
if key in config:
excluded.pop(key, None)
config.pop(key)
return registry.resolve(config, validate=validate)