mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 10:16:27 +03:00
Add serialization tests for tensorizer
This commit is contained in:
parent
924c58bde3
commit
cef547a9f0
25
spacy/tests/serialize/test_serialize_tensorizer.py
Normal file
25
spacy/tests/serialize/test_serialize_tensorizer.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# coding: utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from ..util import make_tempdir
|
||||||
|
from ...pipeline import TokenVectorEncoder as Tensorizer
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_serialize_tensorizer_roundtrip_bytes(en_vocab):
|
||||||
|
tensorizer = Tensorizer(en_vocab)
|
||||||
|
tensorizer.model = tensorizer.Model()
|
||||||
|
tensorizer_b = tensorizer.to_bytes()
|
||||||
|
new_tensorizer = Tensorizer(en_vocab).from_bytes(tensorizer_b)
|
||||||
|
assert new_tensorizer.to_bytes() == tensorizer_b
|
||||||
|
|
||||||
|
|
||||||
|
def test_serialize_tensorizer_roundtrip_disk(en_vocab):
|
||||||
|
tensorizer = Tensorizer(en_vocab)
|
||||||
|
tensorizer.model = tensorizer.Model()
|
||||||
|
with make_tempdir() as d:
|
||||||
|
file_path = d / 'tensorizer'
|
||||||
|
tensorizer.to_disk(file_path)
|
||||||
|
tensorizer_d = Tensorizer(en_vocab).from_disk(file_path)
|
||||||
|
assert tensorizer.to_bytes() == tensorizer_d.to_bytes()
|
Loading…
Reference in New Issue
Block a user