Skip to content

Commit

Permalink
added Raises section to all retrieval metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lucadiliello committed Dec 13, 2021
1 parent 5cbac0e commit a7d0295
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 5 deletions.
6 changes: 6 additions & 0 deletions torchmetrics/retrieval/mean_average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class RetrievalMAP(RetrievalMetric):
Callback that performs the allgather operation on the metric state. When `None`, DDP
will be used to perform the allgather.
Raises:
ValueError:
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
Example:
>>> from torchmetrics import RetrievalMAP
>>> indexes = tensor([0, 0, 0, 1, 1, 1, 1])
Expand Down
6 changes: 6 additions & 0 deletions torchmetrics/retrieval/mean_reciprocal_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class RetrievalMRR(RetrievalMetric):
Callback that performs the allgather operation on the metric state. When `None`, DDP
will be used to perform the allgather.
Raises:
ValueError:
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
Example:
>>> from torchmetrics import RetrievalMRR
>>> indexes = tensor([0, 0, 0, 1, 1, 1, 1])
Expand Down
6 changes: 5 additions & 1 deletion torchmetrics/retrieval/retrieval_fallout.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class RetrievalFallOut(RetrievalMetric):
Raises:
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0.
Example:
>>> from torchmetrics import RetrievalFallOut
Expand Down
6 changes: 5 additions & 1 deletion torchmetrics/retrieval/retrieval_hit_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class RetrievalHitRate(RetrievalMetric):
Raises:
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0.
Example:
>>> from torchmetrics import RetrievalHitRate
Expand Down
6 changes: 6 additions & 0 deletions torchmetrics/retrieval/retrieval_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ class RetrievalMetric(Metric, ABC):
dist_sync_fn:
Callback that performs the allgather operation on the metric state. When `None`, DDP
will be used to perform the allgather.
Raises:
ValueError:
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
"""

indexes: List[Tensor]
Expand Down
6 changes: 5 additions & 1 deletion torchmetrics/retrieval/retrieval_ndcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class RetrievalNormalizedDCG(RetrievalMetric):
Raises:
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0.
Example:
>>> from torchmetrics import RetrievalNormalizedDCG
Expand Down
6 changes: 5 additions & 1 deletion torchmetrics/retrieval/retrieval_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class RetrievalPrecision(RetrievalMetric):
Raises:
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0.
Example:
>>> from torchmetrics import RetrievalPrecision
Expand Down
6 changes: 6 additions & 0 deletions torchmetrics/retrieval/retrieval_r_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class RetrievalRPrecision(RetrievalMetric):
Callback that performs the allgather operation on the metric state. When `None`, DDP
will be used to perform the allgather.
Raises:
ValueError:
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
Example:
>>> from torchmetrics import RetrievalRPrecision
>>> indexes = tensor([0, 0, 0, 1, 1, 1, 1])
Expand Down
6 changes: 5 additions & 1 deletion torchmetrics/retrieval/retrieval_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class RetrievalRecall(RetrievalMetric):
Raises:
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0
If ``empty_target_action`` is not one of ``error``, ``skip``, ``neg`` or ``pos``.
ValueError:
If ``ignore_index`` is not `None` or an integer.
ValueError:
If ``k`` parameter is not `None` or an integer larger than 0.
Example:
>>> from torchmetrics import RetrievalRecall
Expand Down

0 comments on commit a7d0295

Please sign in to comment.