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

minor: added typing to metrics #559

Merged
merged 1 commit into from
Dec 17, 2023
Merged
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
16 changes: 12 additions & 4 deletions pylops/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"psnr",
]

from typing import Optional

import numpy as np
import numpy.typing as npt


def mae(xref, xcmp):
def mae(xref: npt.ArrayLike, xcmp: npt.ArrayLike) -> float:
"""Mean Absolute Error (MAE)

Compute Mean Absolute Error between two vectors
Expand All @@ -30,7 +33,7 @@ def mae(xref, xcmp):
return mae


def mse(xref, xcmp):
def mse(xref: npt.ArrayLike, xcmp: npt.ArrayLike) -> float:
"""Mean Square Error (MSE)

Compute Mean Square Error between two vectors
Expand All @@ -52,7 +55,7 @@ def mse(xref, xcmp):
return mse


def snr(xref, xcmp):
def snr(xref: npt.ArrayLike, xcmp: npt.ArrayLike) -> float:
"""Signal to Noise Ratio (SNR)

Compute Signal to Noise Ratio between two vectors
Expand All @@ -75,7 +78,12 @@ def snr(xref, xcmp):
return snr


def psnr(xref, xcmp, xmax=None, xmin=0.0):
def psnr(
xref: npt.ArrayLike,
xcmp: npt.ArrayLike,
xmax: Optional[float] = None,
xmin: Optional[float] = 0.0,
) -> float:
"""Peak Signal to Noise Ratio (PSNR)

Compute Peak Signal to Noise Ratio between two vectors
Expand Down