Skip to content

Commit

Permalink
Fix typing for kwargs parameter in create_metric_fn (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrit110 authored Nov 13, 2023
1 parent 5facc0f commit d59d1cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ _autosummary
*cyclops_reports*
*dummy_reports*
.mypy_cache
*code-workspace*
6 changes: 3 additions & 3 deletions cyclops/evaluate/metrics/factory.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""Factory for creating metrics."""

from difflib import get_close_matches
from typing import Any, List, Mapping, Optional
from typing import Any, List

from cyclops.evaluate.metrics.metric import _METRIC_REGISTRY, Metric


def create_metric(metric_name: str, **kwargs: Optional[Mapping[str, Any]]) -> Metric:
def create_metric(metric_name: str, **kwargs: Any) -> Metric:
"""Create a metric instance from a name.
Parameters
----------
metric_name : str
The name of the metric.
**kwargs : Mapping[str, Any], optional
**kwargs : Any
The keyword arguments to pass to the metric constructor.
Returns
Expand Down
8 changes: 4 additions & 4 deletions docs/source/tutorials/nihcxr/generate_nihcxr_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ def compute(self) -> npt.NDArray[np.int_]:

specificity = create_metric(
metric_name="specificity",
task="multilabel", # type: ignore[arg-type]
num_labels=len(pathologies), # type: ignore[arg-type]
task="multilabel",
num_labels=len(pathologies),
)

sensitivity = create_metric(
metric_name="sensitivity",
task="multilabel", # type: ignore[arg-type]
num_labels=len(pathologies), # type: ignore[arg-type]
task="multilabel",
num_labels=len(pathologies),
)
# create the slice functions
slice_spec = SliceSpec(spec_list=slices_sex)
Expand Down

0 comments on commit d59d1cc

Please sign in to comment.