mirror of https://github.com/explosion/spaCy.git
Remove references to Python 2 / is_python2
This commit is contained in:
parent
0cdb631e6c
commit
296b5d633b
|
@ -8,7 +8,6 @@ from spacy.kb import KnowledgeBase, Writer
|
||||||
from spacy.vectors import Vectors
|
from spacy.vectors import Vectors
|
||||||
from spacy.language import Language
|
from spacy.language import Language
|
||||||
from spacy.pipeline import Pipe
|
from spacy.pipeline import Pipe
|
||||||
from spacy.compat import is_python2
|
|
||||||
|
|
||||||
|
|
||||||
from ..util import make_tempdir
|
from ..util import make_tempdir
|
||||||
|
@ -97,14 +96,12 @@ def write_obj_and_catch_warnings(obj):
|
||||||
return list(filter(lambda x: isinstance(x, ResourceWarning), warnings_list))
|
return list(filter(lambda x: isinstance(x, ResourceWarning), warnings_list))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x")
|
|
||||||
@pytest.mark.parametrize("obj", objects_to_test[0], ids=objects_to_test[1])
|
@pytest.mark.parametrize("obj", objects_to_test[0], ids=objects_to_test[1])
|
||||||
def test_to_disk_resource_warning(obj):
|
def test_to_disk_resource_warning(obj):
|
||||||
warnings_list = write_obj_and_catch_warnings(obj)
|
warnings_list = write_obj_and_catch_warnings(obj)
|
||||||
assert len(warnings_list) == 0
|
assert len(warnings_list) == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x")
|
|
||||||
def test_writer_with_path_py35():
|
def test_writer_with_path_py35():
|
||||||
writer = None
|
writer = None
|
||||||
with make_tempdir() as d:
|
with make_tempdir() as d:
|
||||||
|
@ -135,13 +132,11 @@ def test_save_and_load_knowledge_base():
|
||||||
pytest.fail(str(e))
|
pytest.fail(str(e))
|
||||||
|
|
||||||
|
|
||||||
if not is_python2:
|
class TestToDiskResourceWarningUnittest(TestCase):
|
||||||
|
def test_resource_warning(self):
|
||||||
|
scenarios = zip(*objects_to_test)
|
||||||
|
|
||||||
class TestToDiskResourceWarningUnittest(TestCase):
|
for scenario in scenarios:
|
||||||
def test_resource_warning(self):
|
with self.subTest(msg=scenario[1]):
|
||||||
scenarios = zip(*objects_to_test)
|
warnings_list = write_obj_and_catch_warnings(scenario[0])
|
||||||
|
self.assertEqual(len(warnings_list), 0)
|
||||||
for scenario in scenarios:
|
|
||||||
with self.subTest(msg=scenario[1]):
|
|
||||||
warnings_list = write_obj_and_catch_warnings(scenario[0])
|
|
||||||
self.assertEqual(len(warnings_list), 0)
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import pytest
|
||||||
import pickle
|
import pickle
|
||||||
from spacy.vocab import Vocab
|
from spacy.vocab import Vocab
|
||||||
from spacy.strings import StringStore
|
from spacy.strings import StringStore
|
||||||
from spacy.compat import is_python2
|
|
||||||
|
|
||||||
from ..util import make_tempdir
|
from ..util import make_tempdir
|
||||||
|
|
||||||
|
@ -135,7 +134,6 @@ def test_serialize_stringstore_roundtrip_disk(strings1, strings2):
|
||||||
assert list(sstore1_d) != list(sstore2_d)
|
assert list(sstore1_d) != list(sstore2_d)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating")
|
|
||||||
@pytest.mark.parametrize("strings,lex_attr", test_strings_attrs)
|
@pytest.mark.parametrize("strings,lex_attr", test_strings_attrs)
|
||||||
def test_pickle_vocab(strings, lex_attr):
|
def test_pickle_vocab(strings, lex_attr):
|
||||||
vocab = Vocab(strings=strings)
|
vocab = Vocab(strings=strings)
|
||||||
|
|
|
@ -6,7 +6,6 @@ from spacy.vectors import Vectors
|
||||||
from spacy.tokenizer import Tokenizer
|
from spacy.tokenizer import Tokenizer
|
||||||
from spacy.strings import hash_string
|
from spacy.strings import hash_string
|
||||||
from spacy.tokens import Doc
|
from spacy.tokens import Doc
|
||||||
from spacy.compat import is_python2
|
|
||||||
|
|
||||||
from ..util import add_vecs_to_vocab, get_cosine, make_tempdir
|
from ..util import add_vecs_to_vocab, get_cosine, make_tempdir
|
||||||
|
|
||||||
|
@ -336,7 +335,6 @@ def test_vocab_prune_vectors():
|
||||||
assert_allclose(similarity, get_cosine(data[0], data[2]), atol=1e-4, rtol=1e-3)
|
assert_allclose(similarity, get_cosine(data[0], data[2]), atol=1e-4, rtol=1e-3)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating")
|
|
||||||
def test_vectors_serialize():
|
def test_vectors_serialize():
|
||||||
data = numpy.asarray([[4, 2, 2, 2], [4, 2, 2, 2], [1, 1, 1, 1]], dtype="f")
|
data = numpy.asarray([[4, 2, 2, 2], [4, 2, 2, 2], [1, 1, 1, 1]], dtype="f")
|
||||||
v = Vectors(data=data, keys=["A", "B", "C"])
|
v = Vectors(data=data, keys=["A", "B", "C"])
|
||||||
|
|
Loading…
Reference in New Issue