Reverting unnecessary changes. Removing unused default values. Renaming variables in find-cli tests.

This commit is contained in:
Raphael Mitsch 2022-09-29 10:39:36 +02:00
parent 9c00b287c1
commit 65e41a52dd
3 changed files with 15 additions and 12 deletions

View File

@ -13,7 +13,6 @@ from ._util import app, Arg, Opt, import_code, setup_gpu
from .. import util
_DEFAULTS = {
"average": "micro",
"n_trials": 10,
"use_gpu": -1,
"gold_preproc": False,

View File

@ -21,7 +21,13 @@ MISSING_VALUES = frozenset([None, 0, ""])
class PRFScore:
"""A precision / recall / F score."""
def __init__(self, *, tp: int = 0, fp: int = 0, fn: int = 0) -> None:
def __init__(
self,
*,
tp: int = 0,
fp: int = 0,
fn: int = 0
) -> None:
self.tp = tp
self.fp = fp
self.fn = fn
@ -37,9 +43,7 @@ class PRFScore:
def __add__(self, other):
return PRFScore(
tp=self.tp + other.tp,
fp=self.fp + other.fp,
fn=self.fn + other.fn,
tp=self.tp + other.tp, fp=self.fp + other.fp, fn=self.fn + other.fn,
)
def score_set(self, cand: set, gold: set) -> None:

View File

@ -889,8 +889,8 @@ def test_cli_find_threshold(capsys):
def init_nlp(
components: Tuple[Tuple[str, Dict[str, Any]], ...] = ()
) -> Tuple[Language, List[Example]]:
_nlp = English()
textcat: TextCategorizer = _nlp.add_pipe( # type: ignore
new_nlp = English()
textcat: TextCategorizer = new_nlp.add_pipe( # type: ignore
factory_name="textcat_multilabel",
name="tc_multi",
config={"threshold": 0.9},
@ -901,17 +901,17 @@ def test_cli_find_threshold(capsys):
# Append additional components to pipeline.
for cfn, comp_config in components:
comp = _nlp.add_pipe(cfn, config=comp_config)
comp = new_nlp.add_pipe(cfn, config=comp_config)
if isinstance(comp, TextCategorizer):
for label in textcat_labels:
comp.add_label(label)
_examples = make_examples(_nlp)
_nlp.initialize(get_examples=lambda: _examples)
new_examples = make_examples(new_nlp)
new_nlp.initialize(get_examples=lambda: new_examples)
for i in range(5):
_nlp.update(_examples)
new_nlp.update(new_examples)
return _nlp, _examples
return new_nlp, new_examples
with make_tempdir() as docs_dir:
# Check whether find_threshold() identifies lowest threshold above 0 as (first) ideal threshold, as this matches