Skip to content

Commit

Permalink
[Error] Remove deprecations in ti.ui in 1.6.0 (#7229)
Browse files Browse the repository at this point in the history
Issue: #7189 

### Brief Summary
  • Loading branch information
lin-hitonami authored Jan 28, 2023
1 parent 80125ef commit 0cb5d21
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions python/taichi/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def make_camera():
>>> camera = ti.ui.make_camera()
"""
warnings.warn(
"`ti.ui.make_camera()` is deprecated, please use `ti.ui.Camera()` instead",
DeprecationWarning)
"`ti.ui.make_camera()` is deprecated, and will be removed in Taichi v1.6.0. "
"Please use `ti.ui.Camera()` instead", DeprecationWarning)
return Camera()


Expand Down
4 changes: 2 additions & 2 deletions python/taichi/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def write_image(self, filename):
filename (str): output filename.
"""
warnings.warn(
"`Window.write_image()` is renamed to `Window.save_image()`",
DeprecationWarning)
"`Window.write_image()` is deprecated, and it will be removed in Taichi v1.6.0. "
"Please use `Window.save_image()` instead.", DeprecationWarning)
return self.save_image(filename)

def save_image(self, filename):
Expand Down
24 changes: 24 additions & 0 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tempfile

import pytest
from taichi._lib import core as _ti_core

import taichi as ti
from tests import test_utils
Expand Down Expand Up @@ -197,6 +198,29 @@ def ker(tex: ti.types.rw_texture(num_dimensions=2, lod=0)):
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():
window = ti.ui.Window("Diff SPH", (256, 256), show_window=False)
with pytest.warns(
DeprecationWarning,
match=
r"`Window\.write_image\(\)` is deprecated, and it will be removed in Taichi v1\.6\.0\. "
):
window.write_image("deprecate.png")


@pytest.mark.skipif(not _ti_core.GGUI_AVAILABLE, reason="GGUI Not Available")
@test_utils.test(arch=ti.cpu)
def test_deprecate_ti_ui_make_camera():
with pytest.warns(
DeprecationWarning,
match=
r"`ti\.ui\.make_camera\(\)` is deprecated, and will be removed in Taichi v1\.6\.0\. "
):
ti.ui.make_camera()


@test_utils.test()
def test_deprecation_in_taichi_init_py():
with pytest.warns(
Expand Down

0 comments on commit 0cb5d21

Please sign in to comment.