Skip to content

Commit

Permalink
Merge pull request #559 from mrava87/dev
Browse files Browse the repository at this point in the history
minor: added typing to metrics
  • Loading branch information
mrava87 authored Dec 17, 2023
2 parents 77eca0f + b67845e commit 64556cd
Showing 1 changed file with 12 additions and 4 deletions.
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

0 comments on commit 64556cd

Please sign in to comment.