Skip to content

Commit

Permalink
[Lang] Remove deprecated ti.Matrix.rotation2d() (taichi-dev#7098)
Browse files Browse the repository at this point in the history
### Brief Summary

`ti.Matrix.rotation2d()` should be removed according to the [deprecation
notice](https://github.com/taichi-dev/taichi/releases/tag/v1.3.0).

Related change: taichi-dev/taichi-aot-demo#107
  • Loading branch information
strongoier authored and quadpixels committed May 13, 2023
1 parent 0cfcffb commit f1b6c47
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 39 deletions.
20 changes: 0 additions & 20 deletions python/taichi/lang/matrix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import numbers
import warnings
from collections.abc import Iterable

import numpy as np
Expand Down Expand Up @@ -836,25 +835,6 @@ def identity(dt, n):
from taichi.lang import matrix_ops # pylint: disable=C0415
return matrix_ops._identity_matrix(n, dt)

@staticmethod
def rotation2d(alpha):
"""Returns the matrix representation of the 2D
anti-clockwise rotation of angle `alpha`. The angle `alpha`
is in radians.
Example::
>>> import math
>>> ti.Matrix.rotation2d(math.pi/4)
[[ 0.70710678 -0.70710678]
[ 0.70710678 0.70710678]]
"""
warnings.warn(
"`ti.Matrix.rotation2d()` will be removed in release v1.4.0. Use `ti.math.rotation2d()` instead.",
DeprecationWarning)
from taichi.lang import matrix_ops # pylint: disable=C0415
return matrix_ops._rotation2d_matrix(alpha)

@classmethod
@python_scope
def field(cls,
Expand Down
6 changes: 0 additions & 6 deletions python/taichi/lang/matrix_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ def _identity_matrix(n: template(), dtype: template()):
for i in static(range(n))], dtype)


@pyfunc
def _rotation2d_matrix(alpha):
return Matrix([[ops_mod.cos(alpha), -ops_mod.sin(alpha)],
[ops_mod.sin(alpha), ops_mod.cos(alpha)]])


@preconditions(
arg_at(0, lambda xs: same_shapes(*xs)),
arg_foreach_check(
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/aot/python_scripts/taichi_sparse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def block1_deactivate_all():
def activate(t: ti.f32):
for i, j in ti.ndrange(n, n):
p = ti.Vector([i, j]) / n
p = ti.Matrix.rotation2d(ti.sin(t)) @ (p - 0.5) + 0.5
p = ti.math.rotation2d(ti.sin(t)) @ (p - 0.5) + 0.5

if taichi_logo(p) == 0:
x[i, j] = 1
Expand Down
1 change: 0 additions & 1 deletion tests/python/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def _get_expected_matrix_apis():
'normalized',
'one',
'outer_product',
'rotation2d',
'rows',
'sum',
'to_list',
Expand Down
10 changes: 0 additions & 10 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
from tests import test_utils


@test_utils.test()
def test_deprecated_matrix_rotation2d():
with pytest.warns(
DeprecationWarning,
match=
r'`ti.Matrix.rotation2d\(\)` will be removed in release v1.4.0. Use `ti.math.rotation2d\(\)` instead.'
):
a = ti.Matrix.rotation2d(math.pi / 2)


@test_utils.test()
def test_deprecate_element_shape_ndarray_annotation():
with pytest.warns(
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_matrix_factories():
@ti.kernel
def fill():
b[0] = ti.Matrix.identity(ti.f32, 2)
b[1] = ti.Matrix.rotation2d(math.pi / 3)
b[1] = ti.math.rotation2d(math.pi / 3)
c[0] = ti.Matrix.zero(ti.f32, 2, 3)
c[1] = ti.Matrix.one(ti.f32, 2, 3)
for i in ti.static(range(3)):
Expand Down

0 comments on commit f1b6c47

Please sign in to comment.