mirror of https://github.com/explosion/spaCy.git
Fix exclude and add test
This commit is contained in:
parent
c0c842ae5b
commit
9016d23cc5
|
@ -7,6 +7,7 @@ from spacy import util
|
||||||
from spacy import prefer_gpu, require_gpu
|
from spacy import prefer_gpu, require_gpu
|
||||||
from spacy.ml._precomputable_affine import PrecomputableAffine
|
from spacy.ml._precomputable_affine import PrecomputableAffine
|
||||||
from spacy.ml._precomputable_affine import _backprop_precomputable_affine_padding
|
from spacy.ml._precomputable_affine import _backprop_precomputable_affine_padding
|
||||||
|
from thinc.api import Optimizer
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -157,3 +158,16 @@ def test_dot_to_dict(dot_notation, expected):
|
||||||
result = util.dot_to_dict(dot_notation)
|
result = util.dot_to_dict(dot_notation)
|
||||||
assert result == expected
|
assert result == expected
|
||||||
assert util.dict_to_dot(result) == dot_notation
|
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
|
||||||
|
|
|
@ -416,10 +416,9 @@ def resolve_training_config(
|
||||||
RETURNS (Dict[str, Any]): The resolved config.
|
RETURNS (Dict[str, Any]): The resolved config.
|
||||||
"""
|
"""
|
||||||
config = config.copy()
|
config = config.copy()
|
||||||
excluded = {}
|
|
||||||
for key in exclude:
|
for key in exclude:
|
||||||
if key in config:
|
if key in config:
|
||||||
excluded.pop(key, None)
|
config.pop(key)
|
||||||
return registry.resolve(config, validate=validate)
|
return registry.resolve(config, validate=validate)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue