fix comparison of constants (#11834)

Co-authored-by: MarcoGorelli <>
This commit is contained in:
Marco Edward Gorelli 2022-11-21 07:12:03 +00:00 committed by GitHub
parent 89bfd06fbd
commit f0d8309a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View File

@ -5,7 +5,7 @@ repos:
- id: black - id: black
language_version: python3.7 language_version: python3.7
additional_dependencies: ['click==8.0.4'] additional_dependencies: ['click==8.0.4']
- repo: https://gitlab.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 5.0.4 rev: 5.0.4
hooks: hooks:
- id: flake8 - id: flake8

View File

@ -1,8 +1,13 @@
import os
import pytest import pytest
from spacy.attrs import IS_ALPHA, LEMMA, ORTH from spacy.attrs import IS_ALPHA, LEMMA, ORTH
from spacy.lang.en import English
from spacy.parts_of_speech import NOUN, VERB from spacy.parts_of_speech import NOUN, VERB
from spacy.vocab import Vocab from spacy.vocab import Vocab
from ..util import make_tempdir
@pytest.mark.issue(1868) @pytest.mark.issue(1868)
def test_issue1868(): def test_issue1868():
@ -59,3 +64,19 @@ def test_vocab_api_contains(en_vocab, text):
def test_vocab_writing_system(en_vocab): def test_vocab_writing_system(en_vocab):
assert en_vocab.writing_system["direction"] == "ltr" assert en_vocab.writing_system["direction"] == "ltr"
assert en_vocab.writing_system["has_case"] is True assert en_vocab.writing_system["has_case"] is True
def test_to_disk():
nlp = English()
with make_tempdir() as d:
nlp.vocab.to_disk(d)
assert "vectors" in os.listdir(d)
assert "lookups.bin" in os.listdir(d)
def test_to_disk_exclude():
nlp = English()
with make_tempdir() as d:
nlp.vocab.to_disk(d, exclude=("vectors", "lookups"))
assert "vectors" not in os.listdir(d)
assert "lookups.bin" not in os.listdir(d)

View File

@ -468,9 +468,9 @@ cdef class Vocab:
setters = ["strings", "vectors"] setters = ["strings", "vectors"]
if "strings" not in exclude: if "strings" not in exclude:
self.strings.to_disk(path / "strings.json") self.strings.to_disk(path / "strings.json")
if "vectors" not in "exclude": if "vectors" not in exclude:
self.vectors.to_disk(path, exclude=["strings"]) self.vectors.to_disk(path, exclude=["strings"])
if "lookups" not in "exclude": if "lookups" not in exclude:
self.lookups.to_disk(path) self.lookups.to_disk(path)
def from_disk(self, path, *, exclude=tuple()): def from_disk(self, path, *, exclude=tuple()):