Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for kwargs parameter in create_metric_fn #503

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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