mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 13:47:13 +03:00
ddd6fda59c
* Add architecture registry * Add test for arch registry * Add error for model architectures
20 lines
478 B
Python
20 lines
478 B
Python
# coding: utf8
|
|
from __future__ import unicode_literals
|
|
|
|
import pytest
|
|
from spacy import register_architecture
|
|
from spacy import get_architecture
|
|
from thinc.v2v import Affine
|
|
|
|
|
|
@register_architecture("my_test_function")
|
|
def create_model(nr_in, nr_out):
|
|
return Affine(nr_in, nr_out)
|
|
|
|
|
|
def test_get_architecture():
|
|
arch = get_architecture("my_test_function")
|
|
assert arch is create_model
|
|
with pytest.raises(KeyError):
|
|
get_architecture("not_an_existing_key")
|