From 4465cad6c5bc188f628dc92183e2e855e26bcfc4 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 22 May 2020 17:42:06 +0200 Subject: [PATCH] Rename spacy.analysis to spacy.pipe_analysis --- spacy/language.py | 23 ++++++++++++++++++----- spacy/{analysis.py => pipe_analysis.py} | 4 +--- spacy/tests/pipeline/test_analysis.py | 8 ++++---- 3 files changed, 23 insertions(+), 12 deletions(-) rename spacy/{analysis.py => pipe_analysis.py} (99%) diff --git a/spacy/language.py b/spacy/language.py index 8c44cf26b..5286bd3b9 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -17,8 +17,8 @@ from .tokens.underscore import Underscore from .vocab import Vocab from .lemmatizer import Lemmatizer from .lookups import Lookups -from .analysis import analyze_pipes, analyze_all_pipes, validate_attrs -from .analysis import count_pipeline_interdependencies +from .pipe_analysis import analyze_pipes, analyze_all_pipes, validate_attrs +from .pipe_analysis import count_pipeline_interdependencies from .gold import Example from .scorer import Scorer from .util import link_vectors_to_models, create_default_optimizer, registry @@ -318,14 +318,18 @@ class Language(object): # check whether we have a proper model config, or load a default one if "model" in factory_cfg and not isinstance(factory_cfg["model"], dict): - warnings.warn(Warnings.W099.format(type=type(factory_cfg["model"]), pipe=name)) + warnings.warn( + Warnings.W099.format(type=type(factory_cfg["model"]), pipe=name) + ) # refer to the model configuration in the cfg settings for this component if "model" in factory_cfg: self.config[name] = {"model": factory_cfg["model"]} # create all objects in the config - factory_cfg = registry.make_from_config({"config": factory_cfg}, validate=True)["config"] + factory_cfg = registry.make_from_config({"config": factory_cfg}, validate=True)[ + "config" + ] model = factory_cfg.get("model", None) if model is not None: del factory_cfg["model"] @@ -519,7 +523,16 @@ class Language(object): def make_doc(self, text): return self.tokenizer(text) - def update(self, examples, dummy=None, *, drop=0.0, sgd=None, losses=None, component_cfg=None): + def update( + self, + examples, + dummy=None, + *, + drop=0.0, + sgd=None, + losses=None, + component_cfg=None, + ): """Update the models in the pipeline. examples (iterable): A batch of `Example` or `Doc` objects. diff --git a/spacy/analysis.py b/spacy/pipe_analysis.py similarity index 99% rename from spacy/analysis.py rename to spacy/pipe_analysis.py index 41591661c..4c0950453 100644 --- a/spacy/analysis.py +++ b/spacy/pipe_analysis.py @@ -187,10 +187,8 @@ def count_pipeline_interdependencies(pipeline): counts = [] for i, assigns in enumerate(pipe_assigns): count = 0 - for requires in pipe_requires[i+1:]: + for requires in pipe_requires[i + 1 :]: if assigns.intersection(requires): count += 1 counts.append(count) return counts - - diff --git a/spacy/tests/pipeline/test_analysis.py b/spacy/tests/pipeline/test_analysis.py index e608f2c34..b826438f5 100644 --- a/spacy/tests/pipeline/test_analysis.py +++ b/spacy/tests/pipeline/test_analysis.py @@ -1,8 +1,8 @@ import spacy.language from spacy.language import Language, component -from spacy.analysis import print_summary, validate_attrs -from spacy.analysis import get_assigns_for_attr, get_requires_for_attr -from spacy.analysis import count_pipeline_interdependencies +from spacy.pipe_analysis import print_summary, validate_attrs +from spacy.pipe_analysis import get_assigns_for_attr, get_requires_for_attr +from spacy.pipe_analysis import count_pipeline_interdependencies from mock import Mock, ANY import pytest @@ -169,7 +169,7 @@ def test_pipe_interdependencies(): name = "fancifier" assigns = ("doc._.fancy",) requires = tuple() - + class FancyNeeder: name = "needer" assigns = tuple()