From a137e8b418f66a740dac5e69fd2ec202cc867c1e Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 21 Feb 2019 09:42:02 +0100 Subject: [PATCH] Fix Pipe.to_bytes() when model uninitialized Closes #3289 --- spacy/pipeline/pipes.pyx | 8 ++------ spacy/tests/regression/test_issue3289.py | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/spacy/pipeline/pipes.pyx b/spacy/pipeline/pipes.pyx index 153e053e2..100b5abfd 100644 --- a/spacy/pipeline/pipes.pyx +++ b/spacy/pipeline/pipes.pyx @@ -145,9 +145,7 @@ class Pipe(object): """Serialize the pipe to a bytestring.""" serialize = OrderedDict() serialize["cfg"] = lambda: srsly.json_dumps(self.cfg) - if self.model in (True, False, None): - serialize["model"] = lambda: self.model - else: + if self.model not in (True, False, None): serialize["model"] = self.model.to_bytes serialize["vocab"] = self.vocab.to_bytes return util.to_bytes(serialize, exclude) @@ -538,9 +536,7 @@ class Tagger(Pipe): def to_bytes(self, **exclude): serialize = OrderedDict() - if self.model in (None, True, False): - serialize['model'] = lambda: self.model - else: + if self.model not in (None, True, False): serialize['model'] = self.model.to_bytes serialize['vocab'] = self.vocab.to_bytes serialize['cfg'] = lambda: srsly.json_dumps(self.cfg) diff --git a/spacy/tests/regression/test_issue3289.py b/spacy/tests/regression/test_issue3289.py index 92b4ec853..ff423ddda 100644 --- a/spacy/tests/regression/test_issue3289.py +++ b/spacy/tests/regression/test_issue3289.py @@ -5,7 +5,6 @@ import pytest from spacy.lang.en import English -@pytest.mark.xfail def test_issue3289(): """Test that Language.to_bytes handles serializing a pipeline component with an uninitialized model."""