Skip to content

Commit

Permalink
Fixed mypy error: changed Dict to Mapping in calc_metrics and `sele…
Browse files Browse the repository at this point in the history
…ct_by_type`.
  • Loading branch information
Семенов Андрей Максимович committed Aug 5, 2024
1 parent 8e0783f commit db3cdff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rectools/metrics/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


def calc_metrics( # noqa # pylint: disable=too-many-branches,too-many-locals,too-many-statements
metrics: tp.Dict[str, MetricAtK],
metrics: tp.Mapping[str, MetricAtK],
reco: pd.DataFrame,
interactions: tp.Optional[pd.DataFrame] = None,
prev_interactions: tp.Optional[pd.DataFrame] = None,
Expand Down
2 changes: 1 addition & 1 deletion rectools/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def is_instance(obj: tp.Any, types: tp.Union[AnyType, tp.Tuple[AnyType, ...]]) -


def select_by_type(
objects: tp.Dict[tp.Any, tp.Any],
objects: tp.Mapping[tp.Any, tp.Any],
types: tp.Union[AnyType, tp.Tuple[AnyType, ...]],
) -> tp.Dict[tp.Any, tp.Any]:
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/metrics/test_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_raises(self, metric: MetricAtK, arg_names: tp.List[str]) -> None:

def test_success_debias(self) -> None:
debias_config = DebiasConfig(iqr_coef=1.5, random_state=32)
debias_metrics = {
debiased_metrics = {
"debiased_precision@3": Precision(k=3, debias_config=debias_config),
"debiased_rprecision@3": Precision(k=3, r_precision=True, debias_config=debias_config),
"debiased_recall@3": Recall(k=3, debias_config=debias_config),
Expand Down Expand Up @@ -207,13 +207,13 @@ def test_success_debias(self) -> None:
debiased_interactions = debias_interactions(self.interactions, config=debias_config)

actual = calc_metrics(
metrics=debias_metrics, # type: ignore
metrics=debiased_metrics,
reco=self.reco,
interactions=self.interactions,
catalog=self.catalog,
)
expected = calc_metrics(
metrics=metrics, # type: ignore
metrics=metrics,
reco=self.reco,
interactions=debiased_interactions,
catalog=self.catalog,
Expand Down

0 comments on commit db3cdff

Please sign in to comment.