mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
bugfix DisabledPipes
This commit is contained in:
parent
18dfb27985
commit
8316bc7d4a
|
@ -1034,6 +1034,9 @@ class Language:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
disable = to_disable
|
disable = to_disable
|
||||||
|
# DisabledPipes will restore the pipes in 'disable' when it's done, so we need to exclude
|
||||||
|
# those pipes that were already disabled.
|
||||||
|
disable = [d for d in disable if d not in self._disabled]
|
||||||
return DisabledPipes(self, disable)
|
return DisabledPipes(self, disable)
|
||||||
|
|
||||||
def make_doc(self, text: str) -> Doc:
|
def make_doc(self, text: str) -> Doc:
|
||||||
|
|
|
@ -129,6 +129,7 @@ def test_enable_pipes_method(nlp, name):
|
||||||
|
|
||||||
@pytest.mark.parametrize("name", ["my_component"])
|
@pytest.mark.parametrize("name", ["my_component"])
|
||||||
def test_disable_pipes_context(nlp, name):
|
def test_disable_pipes_context(nlp, name):
|
||||||
|
"""Test that an enabled component stays enabled after running the context manager."""
|
||||||
nlp.add_pipe("new_pipe", name=name)
|
nlp.add_pipe("new_pipe", name=name)
|
||||||
assert nlp.has_pipe(name)
|
assert nlp.has_pipe(name)
|
||||||
with nlp.select_pipes(disable=name):
|
with nlp.select_pipes(disable=name):
|
||||||
|
@ -136,6 +137,19 @@ def test_disable_pipes_context(nlp, name):
|
||||||
assert nlp.has_pipe(name)
|
assert nlp.has_pipe(name)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("name", ["my_component"])
|
||||||
|
def test_disable_pipes_context_restore(nlp, name):
|
||||||
|
"""Test that a disabled component stays disabled after running the context manager."""
|
||||||
|
nlp.add_pipe("new_pipe", name=name)
|
||||||
|
assert nlp.has_pipe(name)
|
||||||
|
nlp.disable_pipes(name)
|
||||||
|
assert not nlp.has_pipe(name)
|
||||||
|
with nlp.select_pipes(disable=name):
|
||||||
|
assert not nlp.has_pipe(name)
|
||||||
|
assert not nlp.has_pipe(name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_select_pipes_list_arg(nlp):
|
def test_select_pipes_list_arg(nlp):
|
||||||
for name in ["c1", "c2", "c3"]:
|
for name in ["c1", "c2", "c3"]:
|
||||||
nlp.add_pipe("new_pipe", name=name)
|
nlp.add_pipe("new_pipe", name=name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user