Skip to content

Commit

Permalink
better use of void (Lightning-AI#7809)
Browse files Browse the repository at this point in the history
* use void

* format
  • Loading branch information
Borda committed Jun 8, 2021
1 parent 5593b6f commit 4f3af42
Show file tree
Hide file tree
Showing 46 changed files with 111 additions and 68 deletions.
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import Accuracy as _Accuracy

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class Accuracy(_Accuracy):
Expand All @@ -37,4 +37,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.Accuracy`. Will be removed in v1.5.0.
"""
_ = threshold, top_k, subset_accuracy, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn
void(threshold, top_k, subset_accuracy, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/auc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import AUC as _AUC

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class AUC(_AUC):
Expand All @@ -35,4 +35,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.AUC`. Will be removed in v1.5.0.
"""
_ = reorder, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn
void(reorder, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import AUROC as _AUROC

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class AUROC(_AUROC):
Expand All @@ -38,4 +38,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.AUROC`. Will be removed in v1.5.0.
"""
_ = num_classes, pos_label, average, max_fpr, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn
void(num_classes, pos_label, average, max_fpr, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import AveragePrecision as _AveragePrecision

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class AveragePrecision(_AveragePrecision):
Expand All @@ -35,4 +35,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.AveragePrecision`. Will be removed in v1.5.0.
"""
_ = num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group
void(num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import ConfusionMatrix as _ConfusionMatrix

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class ConfusionMatrix(_ConfusionMatrix):
Expand All @@ -36,4 +36,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.ConfusionMatrix`. Will be removed in v1.5.0.
"""
_ = num_classes, normalize, threshold, compute_on_step, dist_sync_on_step, process_group
void(num_classes, normalize, threshold, compute_on_step, dist_sync_on_step, process_group)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/f_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from torchmetrics import F1 as _F1
from torchmetrics import FBeta as _FBeta

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class FBeta(_FBeta):
Expand Down Expand Up @@ -61,4 +61,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.F1`. Will be removed in v1.5.0.
"""
_ = num_classes, threshold, average, multilabel, compute_on_step, dist_sync_on_step, process_group
void(num_classes, threshold, average, multilabel, compute_on_step, dist_sync_on_step, process_group)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/hamming_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import HammingDistance as _HammingDistance

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class HammingDistance(_HammingDistance):
Expand All @@ -35,4 +35,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.HammingDistance`. Will be removed in v1.5.0.
"""
_ = threshold, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn
void(threshold, compute_on_step, dist_sync_on_step, process_group, dist_sync_fn)
8 changes: 5 additions & 3 deletions pytorch_lightning/metrics/classification/iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import IoU as _IoU

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class IoU(_IoU):
Expand All @@ -38,5 +38,7 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.IoU`. Will be removed in v1.5.0.
"""
_ = num_classes, ignore_index, absent_score, threshold, reduction, \
compute_on_step, dist_sync_on_step, process_group
void(
num_classes, ignore_index, absent_score, threshold, reduction, compute_on_step, dist_sync_on_step,
process_group
)
6 changes: 5 additions & 1 deletion pytorch_lightning/metrics/classification/precision_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from torchmetrics import Precision as _Precision
from torchmetrics import Recall as _Recall

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class Precision(_Precision):
Expand Down Expand Up @@ -71,3 +71,7 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.Recall`. Will be removed in v1.5.0.
"""
void(
num_classes, threshold, average, multilabel, mdmc_average, ignore_index, top_k, is_multiclass,
compute_on_step, dist_sync_on_step, process_group, dist_sync_fn
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import PrecisionRecallCurve as _PrecisionRecallCurve

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class PrecisionRecallCurve(_PrecisionRecallCurve):
Expand All @@ -35,4 +35,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.PrecisionRecallCurve`. Will be removed in v1.5.0.
"""
_ = num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group
void(num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group)
4 changes: 2 additions & 2 deletions pytorch_lightning/metrics/classification/roc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import ROC as _ROC

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class ROC(_ROC):
Expand All @@ -35,4 +35,4 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.ROC`. Will be removed in v1.5.0.
"""
_ = num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group
void(num_classes, pos_label, compute_on_step, dist_sync_on_step, process_group)
6 changes: 4 additions & 2 deletions pytorch_lightning/metrics/classification/stat_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from torchmetrics import StatScores as _StatScores

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class StatScores(_StatScores):
Expand All @@ -41,5 +41,7 @@ def __init__(
.. deprecated::
Use :class:`~torchmetrics.StatScores`. Will be removed in v1.5.0.
"""
_ = threshold, top_k, reduce, num_classes, ignore_index, mdmc_reduce, is_multiclass, compute_on_step, \
void(
threshold, top_k, reduce, num_classes, ignore_index, mdmc_reduce, is_multiclass, compute_on_step,
dist_sync_on_step, process_group, dist_sync_fn
)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/compositional.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from torchmetrics import Metric
from torchmetrics.metric import CompositionalMetric as _CompositionalMetric

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


class CompositionalMetric(_CompositionalMetric):
Expand All @@ -33,3 +33,4 @@ def __init__(
.. deprecated::
Use :class:`torchmetrics.metric.CompositionalMetric`. Will be removed in v1.5.0.
"""
void(operator, metric_a, metric_b)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import accuracy as _accuracy

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_accuracy)
Expand All @@ -31,3 +31,4 @@ def accuracy(
.. deprecated::
Use :func:`torchmetrics.functional.accuracy`. Will be removed in v1.5.0.
"""
return void(preds, target, threshold, top_k, subset_accuracy)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/auc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import torch
from torchmetrics.functional import auc as _auc

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_auc)
Expand All @@ -23,3 +23,4 @@ def auc(x: torch.Tensor, y: torch.Tensor, reorder: bool = False) -> torch.Tensor
.. deprecated::
Use :func:`torchmetrics.functional.auc`. Will be removed in v1.5.0.
"""
return void(x, y, reorder)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import auroc as _auroc

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_auroc)
Expand All @@ -33,3 +33,4 @@ def auroc(
.. deprecated::
Use :func:`torchmetrics.functional.auroc`. Will be removed in v1.5.0.
"""
return void(preds, target, num_classes, pos_label, average, max_fpr, sample_weights)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/average_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import average_precision as _average_precision

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_average_precision)
Expand All @@ -31,3 +31,4 @@ def average_precision(
.. deprecated::
Use :func:`torchmetrics.functional.average_precision`. Will be removed in v1.5.0.
"""
return void(preds, target, num_classes, pos_label, sample_weights)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import confusion_matrix as _confusion_matrix

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_confusion_matrix)
Expand All @@ -31,3 +31,4 @@ def confusion_matrix(
.. deprecated::
Use :func:`torchmetrics.functional.confusion_matrix`. Will be removed in v1.5.0.
"""
return void(preds, target, num_classes, normalize, threshold)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/explained_variance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import explained_variance as _explained_variance

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_explained_variance)
Expand All @@ -29,3 +29,4 @@ def explained_variance(
.. deprecated::
Use :func:`torchmetrics.functional.explained_variance`. Will be removed in v1.5.0.
"""
return void(preds, target, multioutput)
4 changes: 3 additions & 1 deletion pytorch_lightning/metrics/functional/f_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from torchmetrics.functional import f1 as _f1
from torchmetrics.functional import fbeta as _fbeta

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_fbeta)
Expand All @@ -34,6 +34,7 @@ def fbeta(
.. deprecated::
Use :func:`torchmetrics.functional.accuracy`. Will be removed in v1.5.0.
"""
return void(preds, target, num_classes, beta, threshold, average, multilabel)


@deprecated_metrics(target=_f1)
Expand All @@ -49,3 +50,4 @@ def f1(
.. deprecated::
Use :func:`torchmetrics.functional.f1`. Will be removed in v1.5.0.
"""
return void(preds, target, num_classes, threshold, average, multilabel)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/hamming_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import torch
from torchmetrics.functional import hamming_distance as _hamming_distance

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_hamming_distance)
Expand All @@ -23,3 +23,4 @@ def hamming_distance(preds: torch.Tensor, target: torch.Tensor, threshold: float
.. deprecated::
Use :func:`torchmetrics.functional.hamming_distance`. Will be removed in v1.5.0.
"""
return void(preds, target, threshold)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/image_gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import image_gradients as _image_gradients

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_image_gradients)
Expand All @@ -25,3 +25,4 @@ def image_gradients(img: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
.. deprecated::
Use :func:`torchmetrics.functional.image_gradients`. Will be removed in v1.5.0.
"""
return void(img)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torchmetrics.functional import iou as _iou

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void
from pytorch_lightning.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_3, _TORCHMETRICS_LOWER_THAN_0_3


Expand All @@ -35,3 +35,4 @@ def iou(
.. deprecated::
Use :func:`torchmetrics.functional.iou`. Will be removed in v1.5.0.
"""
return void(pred, target, ignore_index, absent_score, threshold, num_classes, reduction)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/mean_absolute_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import torch
from torchmetrics.functional import mean_absolute_error as _mean_absolute_error

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_mean_absolute_error)
Expand All @@ -24,3 +24,4 @@ def mean_absolute_error(preds: torch.Tensor, target: torch.Tensor) -> torch.Tens
.. deprecated::
Use :func:`torchmetrics.functional.mean_absolute_error`. Will be removed in v1.5.0.
"""
return void(preds, target)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/mean_relative_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import torch
from torchmetrics.functional.regression.mean_relative_error import mean_relative_error as _mean_relative_error

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_mean_relative_error)
Expand All @@ -24,3 +24,4 @@ def mean_relative_error(preds: torch.Tensor, target: torch.Tensor) -> torch.Tens
.. deprecated::
Use :func:`torchmetrics.functional.regression.mean_relative_error`. Will be removed in v1.5.0.
"""
return void(preds, target)
3 changes: 2 additions & 1 deletion pytorch_lightning/metrics/functional/mean_squared_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import torch
from torchmetrics.functional import mean_squared_error as _mean_squared_error

from pytorch_lightning.metrics.utils import deprecated_metrics
from pytorch_lightning.metrics.utils import deprecated_metrics, void


@deprecated_metrics(target=_mean_squared_error)
Expand All @@ -24,3 +24,4 @@ def mean_squared_error(preds: torch.Tensor, target: torch.Tensor) -> torch.Tenso
.. deprecated::
Use :func:`torchmetrics.functional.mean_squared_error`. Will be removed in v1.5.0.
"""
return void(preds, target)
Loading

0 comments on commit 4f3af42

Please sign in to comment.