Skip to content

Commit 6af0b5c

Browse files
authored
Expose WebP enums (#1974)
1 parent caa9906 commit 6af0b5c

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

tiledb/filter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,9 @@ class WebpFilter(Filter):
754754
lt.FilterOption.WEBP_LOSSLESS,
755755
)
756756

757+
# Expose WebP enums at the top level
758+
WebpInputFormat = lt.WebpInputFormat
759+
757760
def __init__(
758761
self,
759762
input_format: lt.WebpInputFormat = None,

tiledb/tests/test_webp.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"format, quality, lossless",
1818
[
1919
(
20-
tiledb.filter.lt.WebpInputFormat.WEBP_RGB,
20+
tiledb.filter.WebpFilter.WebpInputFormat.WEBP_RGB,
2121
100.0,
2222
False,
2323
), # Test setting format with enum values
24-
(tiledb.filter.lt.WebpInputFormat.WEBP_BGR, 50.0, True),
25-
(tiledb.filter.lt.WebpInputFormat.WEBP_RGBA, 25.5, False),
24+
(tiledb.filter.WebpFilter.WebpInputFormat.WEBP_BGR, 50.0, True),
25+
(tiledb.filter.WebpFilter.WebpInputFormat.WEBP_RGBA, 25.5, False),
2626
(4, 0.0, True), # Test setting format with integral type
2727
],
2828
)
@@ -31,7 +31,7 @@ def test_webp_ctor(format, quality, lossless):
3131
input_format=format, quality=quality, lossless=lossless
3232
)
3333
np.testing.assert_equal(
34-
webp_filter.input_format, tiledb.filter.lt.WebpInputFormat(format)
34+
webp_filter.input_format, tiledb.filter.WebpFilter.WebpInputFormat(format)
3535
)
3636
np.testing.assert_equal(webp_filter.quality, quality)
3737
np.testing.assert_equal(webp_filter.lossless, lossless)
@@ -117,16 +117,18 @@ def make_image_data(width, height, pixel_depth):
117117
@pytest.mark.parametrize(
118118
"colorspace",
119119
[
120-
tiledb.filter.lt.WebpInputFormat.WEBP_RGB,
121-
tiledb.filter.lt.WebpInputFormat.WEBP_BGR,
122-
tiledb.filter.lt.WebpInputFormat.WEBP_RGBA,
123-
tiledb.filter.lt.WebpInputFormat.WEBP_BGRA,
120+
tiledb.filter.WebpFilter.WebpInputFormat.WEBP_RGB,
121+
tiledb.filter.WebpFilter.WebpInputFormat.WEBP_BGR,
122+
tiledb.filter.WebpFilter.WebpInputFormat.WEBP_RGBA,
123+
tiledb.filter.WebpFilter.WebpInputFormat.WEBP_BGRA,
124124
],
125125
)
126126
@pytest.mark.parametrize("lossless", [True, False])
127127
def test_webp_filter(width, height, colorspace, lossless):
128128
pixel_depth = (
129-
3 if int(colorspace) < int(tiledb.filter.lt.WebpInputFormat.WEBP_RGBA) else 4
129+
3
130+
if int(colorspace) < int(tiledb.filter.WebpFilter.WebpInputFormat.WEBP_RGBA)
131+
else 4
130132
)
131133
data = make_image_data(width, height, pixel_depth)
132134
data = np.array(data, dtype=np.uint8).reshape(height, width * pixel_depth)

0 commit comments

Comments
 (0)