Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

fix linter and mypy error for laplacian

edgarribaf08c7e0414b5
diff --git a/mypy_files.txt b/mypy_files.txt
index faa430ee5..37b43dbfa 100644
--- a/mypy_files.txt
+++ b/mypy_files.txt
@@ -3,6 +3,7 @@ torchgeometry/core/depth_warper.py
torchgeometry/core/pinhole.py
torchgeometry/image/gaussian.py
torchgeometry/image/color.py
+torchgeometry/image/laplacian.py
torchgeometry/losses/ssim.py
torchgeometry/losses/dice.py
torchgeometry/losses/focal.py
diff --git a/test/test_image.py b/test/test_image.py
index a664bc28c..04c66910c 100644
--- a/test/test_image.py
+++ b/test/test_image.py
@@ -49,7 +49,7 @@ class TestGaussianBlur:
input = utils.tensor_to_gradcheck_var(input) # to var
assert gradcheck(image.gaussian_blur, (input, kernel_size, sigma,),
raise_exception=True)
-
+
def test_jit(self):
batch_size, channels, height, width = 2, 3, 64, 64
img = torch.ones(batch_size, channels, height, width)
@@ -101,8 +101,8 @@ class TestLaplacian:
input = utils.tensor_to_gradcheck_var(input)
assert gradcheck(image.laplacian, (input, kernel_size,),
raise_exception=True)
-
-
+
+
class TestRgbToGrayscale:
def test_rgb_to_grayscale(self):
channels, height, width = 3, 4, 5
@@ -126,4 +126,4 @@ class TestRgbToGrayscale:
img = torch.ones(batch_size, channels, height, width)
gray = image.RgbToGrayscale()
gray_traced = torch.jit.trace(image.RgbToGrayscale(), img)
- assert_allclose(gray(img), gray_traced(img))
\ No newline at end of file
+ assert_allclose(gray(img), gray_traced(img))
diff --git a/torchgeometry/image/__init__.py b/torchgeometry/image/__init__.py
index 622d18e46..9788c1e23 100644
--- a/torchgeometry/image/__init__.py
+++ b/torchgeometry/image/__init__.py
@@ -2,4 +2,4 @@ from .gaussian import get_gaussian_kernel, get_gaussian_kernel2d
from .gaussian import GaussianBlur, gaussian_blur
from .laplacian import get_laplacian_kernel, get_laplacian_kernel2d
from .laplacian import Laplacian, laplacian
-from .color import rgb_to_grayscale, RgbToGrayscale
\ No newline at end of file
+from .color import rgb_to_grayscale, RgbToGrayscale
diff --git a/torchgeometry/image/laplacian.py b/torchgeometry/image/laplacian.py
index 7692ee5f9..4890994c2 100644
--- a/torchgeometry/image/laplacian.py
+++ b/torchgeometry/image/laplacian.py
@@ -124,7 +124,7 @@ class Laplacian(nn.Module):
computed = (kernel_size - 1) // 2
return computed
- def forward(self, x: torch.Tensor):
+ def forward(self, x: torch.Tensor): # type: ignore
if not torch.is_tensor(x):
raise TypeError("Input x type is not a torch.Tensor. Got {}"
.format(type(x)))