Skip to content

Commit

Permalink
[misc] Remove deprecated kwarg in rw_texture type annotations (taichi…
Browse files Browse the repository at this point in the history
…-dev#7267)

Issue: #

### Brief Summary

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ailzhang and pre-commit-ci[bot] authored Feb 2, 2023
1 parent e0e3f4a commit c94dea8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 85 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/scripts/aot-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export TI_SKIP_VERSION_CHECK=ON
export TI_CI=1

# IF YOU PIN THIS TO A COMMIT/BRANCH, YOU'RE RESPONSIBLE TO REVERT IT BACK TO MASTER ONCE MERGED.
export TAICHI_AOT_DEMO_URL=https://github.com/PENGUINLIONG/taichi-aot-demo
export TAICHI_AOT_DEMO_BRANCH=opengl-demo-alt
export TAICHI_AOT_DEMO_URL=https://github.com/taichi-dev/taichi-aot-demo
export TAICHI_AOT_DEMO_BRANCH=master
export TAICHI_UNITY2_URL=https://github.com/taichi-dev/taichi-unity2
export TAICHI_UNITY2_BRANCH=main

Expand Down
22 changes: 2 additions & 20 deletions python/taichi/types/texture_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

from taichi.lang.enums import Format
from taichi.lang.exception import TaichiCompilationError
from taichi.types.primitive_types import f16, f32, i8, i16, i32, u8, u16, u32
Expand Down Expand Up @@ -63,29 +61,13 @@ class RWTextureType:
Args:
num_dimensions (int): Number of dimensions. For examples for a 2D texture this should be `2`.
num_channels (int): Number of channels in the texture.
channel_format (DataType): Data type of texture
lod (float): Specifies the explicit level-of-detail.
fmt (ti.Format): Color format of texture
"""
def __init__(self,
num_dimensions,
num_channels=None,
channel_format=None,
lod=0,
fmt=None):
def __init__(self, num_dimensions, lod=0, fmt=None):
self.num_dimensions = num_dimensions
if fmt is None:
warnings.warn(
"Specifying num_channels and channel_format is deprecated and will be removed in v1.5.0, please specify fmt instead.",
DeprecationWarning)
if num_channels is None or channel_format is None:
raise TaichiCompilationError(
"Incomplete type info for rw_texture, please specify its fmt (ti.Format)"
)
self.num_channels = num_channels
self.channel_format = channel_format
self.fmt = TY_CH2FORMAT[(self.channel_format, self.num_channels)]
raise TaichiCompilationError("fmt is required for rw_texture type")
else:
self.channel_format, self.num_channels = FORMAT2TY_CH[fmt]
self.fmt = fmt
Expand Down
63 changes: 0 additions & 63 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,69 +135,6 @@ def func():
func()


@test_utils.test(arch=ti.vulkan)
def test_deprecated_rwtexture_type():
n = 128

with pytest.warns(
DeprecationWarning,
match=
r"Specifying num_channels and channel_format is deprecated and will be removed in v1.5.0, please specify fmt instead"
):

@ti.kernel
def ker(tex: ti.types.rw_texture(num_dimensions=2,
num_channels=1,
channel_format=ti.f32,
lod=0)):
for i, j in ti.ndrange(n, n):
ret = ti.cast(1, ti.f32)
tex.store(ti.Vector([i, j]), ti.Vector([ret, 0.0, 0.0, 0.0]))


# Note: will be removed in v1.5.0
@test_utils.test(arch=ti.vulkan)
def test_incomplete_info_rwtexture():
n = 128

with pytest.raises(
ti.TaichiCompilationError,
match=r"Incomplete type info for rw_texture, please specify its fmt"
):

@ti.kernel
def ker(tex: ti.types.rw_texture(num_dimensions=2,
channel_format=ti.f32,
lod=0)):
for i, j in ti.ndrange(n, n):
ret = ti.cast(1, ti.f32)
tex.store(ti.Vector([i, j]), ti.Vector([ret, 0.0, 0.0, 0.0]))

with pytest.raises(
ti.TaichiCompilationError,
match=r"Incomplete type info for rw_texture, please specify its fmt"
):

@ti.kernel
def ker(tex: ti.types.rw_texture(num_dimensions=2,
num_channels=2,
lod=0)):
for i, j in ti.ndrange(n, n):
ret = ti.cast(1, ti.f32)
tex.store(ti.Vector([i, j]), ti.Vector([ret, 0.0, 0.0, 0.0]))

with pytest.raises(
ti.TaichiCompilationError,
match=r"Incomplete type info for rw_texture, please specify its fmt"
):

@ti.kernel
def ker(tex: ti.types.rw_texture(num_dimensions=2, lod=0)):
for i, j in ti.ndrange(n, n):
ret = ti.cast(1, ti.f32)
tex.store(ti.Vector([i, j]), ti.Vector([ret, 0.0, 0.0, 0.0]))


@pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available")
@test_utils.test(arch=ti.cpu)
def test_deprecate_ti_ui_window():
Expand Down

0 comments on commit c94dea8

Please sign in to comment.