Skip to content

Commit

Permalink
[Lang] Remove a.atomic(b)
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-hitonami authored and taichi-gardener committed May 6, 2023
1 parent c9aa84f commit 7735030
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
20 changes: 0 additions & 20 deletions python/taichi/lang/common_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

from taichi.lang import ops
from taichi.lang.util import in_python_scope
from taichi.types import primitive_types
Expand All @@ -8,24 +6,6 @@
class TaichiOperations:
"""The base class of taichi operations of expressions. Subclasses: :class:`~taichi.lang.expr.Expr`, :class:`~taichi.lang.matrix.Matrix`"""

__deprecated_atomic_ops__ = {
"atomic_add": "_atomic_add",
"atomic_mul": "_atomic_mul",
"atomic_and": "_atomic_and",
"atomic_or": "_atomic_or",
"atomic_sub": "_atomic_sub",
"atomic_xor": "_atomic_xor",
}

def __getattr__(self, item):
if item in TaichiOperations.__deprecated_atomic_ops__:
warnings.warn(
f"a.{item}(b) is deprecated, and it will be removed in Taichi v1.6.0. Please use ti.{item}(a, b) instead.",
DeprecationWarning,
)
return getattr(self, TaichiOperations.__deprecated_atomic_ops__[item])
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{item}'")

def __neg__(self):
return ops.neg(self)

Expand Down
15 changes: 0 additions & 15 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@
from tests import test_utils


@test_utils.test()
def test_deprecate_a_atomic_b():
with pytest.warns(
DeprecationWarning,
match=r"a\.atomic_add\(b\) is deprecated, and it will be removed in Taichi v1.6.0.",
):

@ti.kernel
def func():
a = 1
a.atomic_add(2)

func()


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

0 comments on commit 7735030

Please sign in to comment.