π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
test(color): narrow pytest.raises blocks for Ruff PT012 (#5102)
Daniele Loru4f5e92706ee0
diff --git a/tests/color/test_gray.py b/tests/color/test_gray.pyindex a70b3cad8..f1e6e62c5 100644--- a/tests/color/test_gray.py+++ b/tests/color/test_gray.py@@ -42,16 +42,16 @@ class TestGrayscaleToRgb(BaseTester):with pytest.raises(TypeCheckError):assert kornia.color.grayscale_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.grayscale_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.grayscale_to_rgb(img)+ img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)assert kornia.color.grayscale_to_rgb(img)def test_opencv(self, device, dtype):@@ -147,17 +147,17 @@ class TestRgbToGrayscale(BaseTester):with pytest.raises(TypeCheckError):assert kornia.color.rgb_to_grayscale([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_grayscale(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_grayscale(img)+ img = torch.ones(3, 1, 1, device=device, dtype=dtype)+ rgb_weights = torch.tensor([0.2, 0.8])with pytest.raises(ValueError):- img = torch.ones(3, 1, 1, device=device, dtype=dtype)- rgb_weights = torch.tensor([0.2, 0.8])assert kornia.color.rgb_to_grayscale(img, rgb_weights=rgb_weights)def test_unsupported_dtype_raises(self, device):@@ -262,12 +262,12 @@ class TestBgrToGrayscale(BaseTester):with pytest.raises(TypeCheckError):assert kornia.color.bgr_to_grayscale([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.bgr_to_grayscale(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.bgr_to_grayscale(img)def test_opencv(self, device, dtype):diff --git a/tests/color/test_hls.py b/tests/color/test_hls.pyindex d7cf31872..7f591738e 100644--- a/tests/color/test_hls.py+++ b/tests/color/test_hls.py@@ -41,12 +41,12 @@ class TestRgbToHls(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_hls([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_hls(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_hls(img)def test_unit(self, device, dtype):@@ -223,12 +223,12 @@ class TestHlsToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.hls_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.hls_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.hls_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_hsv.py b/tests/color/test_hsv.pyindex eb1ff6c88..54d3af816 100644--- a/tests/color/test_hsv.py+++ b/tests/color/test_hsv.py@@ -41,12 +41,12 @@ class TestRgbToHsv(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_hsv([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_hsv(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_hsv(img)def test_unit(self, device, dtype):@@ -187,12 +187,12 @@ class TestHsvToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.hsv_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.hsv_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.hsv_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_lab.py b/tests/color/test_lab.pyindex 9e93d1039..228bccd46 100644--- a/tests/color/test_lab.py+++ b/tests/color/test_lab.py@@ -39,12 +39,12 @@ class TestRgbToLab(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_lab([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_lab(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_lab(img)def test_unit(self, device, dtype):@@ -150,12 +150,12 @@ class TestLabToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.lab_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.lab_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.lab_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_luv.py b/tests/color/test_luv.pyindex c8107845d..38e9eb723 100644--- a/tests/color/test_luv.py+++ b/tests/color/test_luv.py@@ -39,12 +39,12 @@ class TestRgbToLuv(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_luv([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_luv(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_luv(img)def test_unit(self, device, dtype):@@ -152,12 +152,12 @@ class TestLuvToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.luv_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.luv_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.luv_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_raw.py b/tests/color/test_raw.pyindex 311afb78b..ca8b9d572 100644--- a/tests/color/test_raw.py+++ b/tests/color/test_raw.py@@ -43,26 +43,26 @@ class TestRawToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.raw_to_rgb([0.0], kornia.color.CFA.BG)+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.raw_to_rgb(img, kornia.color.CFA.GB)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.raw_to_rgb(img, kornia.color.CFA.RG)+ img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)assert kornia.color.raw_to_rgb(img, kornia.color.CFA.GR)# dimensionality test+ img = torch.ones(3, 2, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(3, 2, 1, device=device, dtype=dtype)assert kornia.color.raw_to_rgb(img, kornia.color.CFA.GR)# dimensionality test+ img = torch.ones(3, 1, 2, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(3, 1, 2, device=device, dtype=dtype)assert kornia.color.raw_to_rgb(img, kornia.color.CFA.GR)# With he current implementations we should get back an identical raw representation when doing raw -> rgb -> raw@@ -171,8 +171,8 @@ class TestRgbToRaw(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_raw([0.0], kornia.color.raw.CFA.RG)+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_raw(img, kornia.color.raw.CFA.BG)# Reverse test in rawtorgb is sufficient functional test@@ -223,29 +223,29 @@ class TestRawToRgb2x2Downscaled(BaseTester):kornia.color.raw_to_rgb_2x2_downscaled([0.0], kornia.color.CFA.BG)assert "Input type is not a torch.Tensor" in str(errinf.value)+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError) as errinf:- img = torch.ones(1, 1, device=device, dtype=dtype)kornia.color.raw_to_rgb_2x2_downscaled(img, kornia.color.CFA.GB)assert "Shape dimension mismatch" in str(errinf.value) or "Expected shape" in str(errinf.value)+ img = torch.ones(2, 2, 2, device=device, dtype=dtype)with pytest.raises(ShapeError) as errinf:- img = torch.ones(2, 2, 2, device=device, dtype=dtype)kornia.color.raw_to_rgb_2x2_downscaled(img, kornia.color.CFA.RG)assert "Shape dimension mismatch" in str(errinf.value) or "Expected shape" in str(errinf.value)+ img = torch.ones(1, 3, 2, device=device, dtype=dtype)with pytest.raises(Exception) as errinf:- img = torch.ones(1, 3, 2, device=device, dtype=dtype)kornia.color.raw_to_rgb_2x2_downscaled(img, kornia.color.CFA.GR)assert "Input H&W must be evenly divisible by 2. Got" in str(errinf)+ img = torch.ones(1, 2, 3, device=device, dtype=dtype)with pytest.raises(Exception) as errinf:- img = torch.ones(1, 2, 3, device=device, dtype=dtype)kornia.color.raw_to_rgb_2x2_downscaled(img, kornia.color.CFA.GR)assert "Input H&W must be evenly divisible by 2. Got" in str(errinf)+ img = torch.ones(1, 4, 8, device=device, dtype=dtype)+ nonexistent_cfa = 195162495283with pytest.raises(ValueError) as errinf:- img = torch.ones(1, 4, 8, device=device, dtype=dtype)- nonexistent_cfa = 195162495283kornia.color.raw_to_rgb_2x2_downscaled(img, nonexistent_cfa)assert "Unsupported CFA Got" in str(errinf)diff --git a/tests/color/test_rgb.py b/tests/color/test_rgb.pyindex 1c3c582ae..3109bf142 100644--- a/tests/color/test_rgb.py+++ b/tests/color/test_rgb.py@@ -39,23 +39,23 @@ class TestRgbToBgr(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_bgr([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_bgr(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_bgr(img)with pytest.raises(TypeError):assert kornia.color.bgr_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.bgr_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.bgr_to_rgb(img)def test_back_and_forth(self, device, dtype):@@ -133,32 +133,32 @@ class TestRgbToRgba(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_rgba([0.0], 0.0)+ img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)with pytest.raises(TypeError):- img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_rgba(img)+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_rgba(img, 0.0)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_rgba(img, 0.0)+ img = torch.ones(3, 1, 1, device=device, dtype=dtype)with pytest.raises(TypeError):- img = torch.ones(3, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_rgba(img, "alpha_str")# rgba to rgbwith pytest.raises(TypeError):assert kornia.color.rgba_to_rgb(0.0)+ img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 3, 1, 1, device=device, dtype=dtype)assert kornia.color.rgba_to_rgb(img)+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgba_to_rgb(img)def test_back_and_forth_rgb(self, device, dtype):@@ -317,23 +317,23 @@ class TestLinearRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_linear_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_linear_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_linear_rgb(img)with pytest.raises(TypeError):assert kornia.color.linear_rgb_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.linear_rgb_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.linear_rgb_to_rgb(img)def test_back_and_forth(self, device, dtype):diff --git a/tests/color/test_xyz.py b/tests/color/test_xyz.pyindex 3ff6db227..03137f309 100644--- a/tests/color/test_xyz.py+++ b/tests/color/test_xyz.py@@ -52,12 +52,12 @@ class TestRgbToXyz(BaseTester):with pytest.raises(TypeCheckError):assert kornia.color.rgb_to_xyz([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_xyz(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_xyz(img)def test_unit(self, device, dtype):@@ -179,12 +179,12 @@ class TestXyzToRgb(BaseTester):with pytest.raises(TypeCheckError):assert kornia.color.xyz_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.xyz_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.xyz_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_ycbcr.py b/tests/color/test_ycbcr.pyindex e795272ac..f2dd2b757 100644--- a/tests/color/test_ycbcr.py+++ b/tests/color/test_ycbcr.py@@ -46,12 +46,12 @@ class TestRgbToYcbcr(BaseTester):with pytest.raises(TypeError):assert kornia.color.rgb_to_ycbcr([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_ycbcr(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.rgb_to_ycbcr(img)def test_unit(self, device, dtype):@@ -153,12 +153,12 @@ class TestYcbcrToRgb(BaseTester):with pytest.raises(TypeError):assert kornia.color.ycbcr_to_rgb([0.0])+ img = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(1, 1, device=device, dtype=dtype)assert kornia.color.ycbcr_to_rgb(img)+ img = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ValueError):- img = torch.ones(2, 1, 1, device=device, dtype=dtype)assert kornia.color.ycbcr_to_rgb(img)def test_unit(self, device, dtype):diff --git a/tests/color/test_yuv.py b/tests/color/test_yuv.pyindex 786fd0557..f01a81a23 100644--- a/tests/color/test_yuv.py+++ b/tests/color/test_yuv.py@@ -719,51 +719,51 @@ class TestYuv420ToRgb(BaseTester):with pytest.raises((TypeError, AttributeError)):kornia.color.yuv420_to_rgb([0.0], [0.0])+ imgy = torch.ones(1, 1, device=device, dtype=dtype)+ imguv = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 1, device=device, dtype=dtype)- imguv = torch.ones(1, 1, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)# Luma H and W must both be even.+ imgy = torch.ones(1, 3, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 1, 2, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 3, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 1, 2, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)+ imgy = torch.ones(1, 4, 3, device=device, dtype=dtype)+ imguv = torch.ones(2, 2, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 3, device=device, dtype=dtype)- imguv = torch.ones(2, 2, 1, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)# Chroma must be exactly half the luma in both axes.+ imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 4, 2, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 4, 2, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)+ imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 2, 4, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 2, 4, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)# Luma must be single-channel. (1, 2, 2) / (2, 1, 1) is the accepted shape; the same# sizes with a 2-channel luma are rejected by the channel slot of the shape spec, which# the rank case above does not reach.+ imgy = torch.ones(2, 2, 2, device=device, dtype=dtype)+ imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(2, 2, 2, device=device, dtype=dtype)- imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)# Regression for #4056: a zero-sized chroma dimension is still a shape violation and must# be reported as ShapeError, not the bare ZeroDivisionError the old ratio guard threw.+ imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 2, 0, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 2, 0, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)+ imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 0, 2, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 0, 2, device=device, dtype=dtype)kornia.color.yuv420_to_rgb(imgy, imguv)def test_empty_input(self, device, dtype):@@ -865,42 +865,42 @@ class TestYuv422ToRgb(BaseTester):with pytest.raises((TypeError, AttributeError)):kornia.color.yuv422_to_rgb([0.0], [0.0])+ imgy = torch.ones(1, 1, device=device, dtype=dtype)+ imguv = torch.ones(1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 1, device=device, dtype=dtype)- imguv = torch.ones(1, 1, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)# Luma W must be even.+ imgy = torch.ones(1, 4, 3, device=device, dtype=dtype)+ imguv = torch.ones(2, 4, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 3, device=device, dtype=dtype)- imguv = torch.ones(2, 4, 1, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)# Chroma must be exactly half the luma width.+ imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)+ imguv = torch.ones(2, 4, 4, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 4, device=device, dtype=dtype)- imguv = torch.ones(2, 4, 4, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)# Luma must be single-channel: rejected by the channel slot of the shape spec, which the# rank case above does not reach. Note this is *not* a width-relation case -- 2/1 == 2# holds.+ imgy = torch.ones(2, 2, 2, device=device, dtype=dtype)+ imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(2, 2, 2, device=device, dtype=dtype)- imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)# 4:2:2 subsamples width only, so chroma keeps the full luma height.+ imgy = torch.ones(1, 2, 2, device=device, dtype=dtype)+ imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 2, 2, device=device, dtype=dtype)- imguv = torch.ones(2, 1, 1, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)# Regression for #4056: a zero-sized chroma width is still a shape violation and must be# reported as ShapeError, not the bare ZeroDivisionError the old ratio guard threw.+ imgy = torch.ones(1, 4, 6, device=device, dtype=dtype)+ imguv = torch.ones(2, 4, 0, device=device, dtype=dtype)with pytest.raises(ShapeError):- imgy = torch.ones(1, 4, 6, device=device, dtype=dtype)- imguv = torch.ones(2, 4, 0, device=device, dtype=dtype)kornia.color.yuv422_to_rgb(imgy, imguv)def test_empty_input(self, device, dtype):