From 126268ce50d08d38aefa15e7925632c156c792d4 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Mon, 5 Oct 2020 21:58:18 +0200 Subject: [PATCH] Auto-format [ci skip] --- spacy/lang/uk/__init__.py | 4 +++- spacy/lang/zh/__init__.py | 6 ++---- spacy/tests/doc/test_retokenize_split.py | 10 +++++++--- spacy/tests/pipeline/test_pipe_methods.py | 2 +- spacy/tests/test_models.py | 8 ++++---- spacy/training/augment.py | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spacy/lang/uk/__init__.py b/spacy/lang/uk/__init__.py index 0abe9170e..24c88e5a7 100644 --- a/spacy/lang/uk/__init__.py +++ b/spacy/lang/uk/__init__.py @@ -26,7 +26,9 @@ class Ukrainian(Language): default_config={"model": None, "mode": "pymorphy2"}, default_score_weights={"lemma_acc": 1.0}, ) -def make_lemmatizer(nlp: Language, model: Optional[Model], name: str, mode: str, overwrite: bool = False,): +def make_lemmatizer( + nlp: Language, model: Optional[Model], name: str, mode: str, overwrite: bool = False +): return UkrainianLemmatizer(nlp.vocab, model, name, mode=mode, overwrite=overwrite) diff --git a/spacy/lang/zh/__init__.py b/spacy/lang/zh/__init__.py index ed988c1ba..30560ed0d 100644 --- a/spacy/lang/zh/__init__.py +++ b/spacy/lang/zh/__init__.py @@ -54,9 +54,7 @@ def create_chinese_tokenizer(segmenter: Segmenter = Segmenter.char): class ChineseTokenizer(DummyTokenizer): - def __init__( - self, nlp: Language, segmenter: Segmenter = Segmenter.char, - ): + def __init__(self, nlp: Language, segmenter: Segmenter = Segmenter.char): self.vocab = nlp.vocab if isinstance(segmenter, Segmenter): segmenter = segmenter.value @@ -87,7 +85,7 @@ class ChineseTokenizer(DummyTokenizer): if pkuseg_user_dict is None: pkuseg_user_dict = pkuseg_model self.pkuseg_seg = try_pkuseg_import( - pkuseg_model=pkuseg_model, pkuseg_user_dict=pkuseg_user_dict, + pkuseg_model=pkuseg_model, pkuseg_user_dict=pkuseg_user_dict ) def __call__(self, text: str) -> Doc: diff --git a/spacy/tests/doc/test_retokenize_split.py b/spacy/tests/doc/test_retokenize_split.py index da4a46a47..30f945165 100644 --- a/spacy/tests/doc/test_retokenize_split.py +++ b/spacy/tests/doc/test_retokenize_split.py @@ -209,9 +209,13 @@ def test_doc_retokenizer_split_norm(en_vocab): # Retokenize to split out the words in the token at doc[2]. token = doc[2] with doc.retokenize() as retokenizer: - retokenizer.split(token, ["brown", "fox", "jumps", "over", "the"], heads=[(token, idx) for idx in range(5)]) + retokenizer.split( + token, + ["brown", "fox", "jumps", "over", "the"], + heads=[(token, idx) for idx in range(5)], + ) - assert doc[9].text == "w/" + assert doc[9].text == "w/" assert doc[9].norm_ == "with" - assert doc[5].text == "over" + assert doc[5].text == "over" assert doc[5].norm_ == "over" diff --git a/spacy/tests/pipeline/test_pipe_methods.py b/spacy/tests/pipeline/test_pipe_methods.py index a4297a1d1..4b96992e1 100644 --- a/spacy/tests/pipeline/test_pipe_methods.py +++ b/spacy/tests/pipeline/test_pipe_methods.py @@ -350,7 +350,7 @@ def test_pipe_methods_frozen(): @pytest.mark.parametrize( - "pipe", ["tagger", "parser", "ner", "textcat", "morphologizer"], + "pipe", ["tagger", "parser", "ner", "textcat", "morphologizer"] ) def test_pipe_label_data_exports_labels(pipe): nlp = Language() diff --git a/spacy/tests/test_models.py b/spacy/tests/test_models.py index bad964786..17408f7e8 100644 --- a/spacy/tests/test_models.py +++ b/spacy/tests/test_models.py @@ -64,7 +64,7 @@ def get_tok2vec_kwargs(): width=32, rows=[500, 500, 500], attrs=["NORM", "PREFIX", "SHAPE"], - include_static_vectors=False + include_static_vectors=False, ), "encode": MaxoutWindowEncoder( width=32, depth=2, maxout_pieces=2, window_size=1 @@ -81,7 +81,7 @@ def test_multi_hash_embed(): width=32, rows=[500, 500, 500], attrs=["NORM", "PREFIX", "SHAPE"], - include_static_vectors=False + include_static_vectors=False, ) hash_embeds = [node for node in embed.walk() if node.name == "hashembed"] assert len(hash_embeds) == 3 @@ -96,11 +96,11 @@ def test_multi_hash_embed(): width=32, rows=[1000, 50, 250], attrs=["NORM", "PREFIX", "SHAPE"], - include_static_vectors=False + include_static_vectors=False, ) hash_embeds = [node for node in embed.walk() if node.name == "hashembed"] assert [he.get_dim("nV") for he in hash_embeds] == [1000, 50, 250] - + @pytest.mark.parametrize( "seed,model_func,kwargs", diff --git a/spacy/training/augment.py b/spacy/training/augment.py index e76ee49f7..13ae45bd2 100644 --- a/spacy/training/augment.py +++ b/spacy/training/augment.py @@ -64,7 +64,7 @@ def dont_augment(nlp: "Language", example: Example) -> Iterator[Example]: def lower_casing_augmenter( - nlp: "Language", example: Example, *, level: float, + nlp: "Language", example: Example, *, level: float ) -> Iterator[Example]: if random.random() >= level: yield example