Skip to content

Commit

Permalink
[Lang] Cancel deprecating native min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-hitonami committed May 5, 2023
1 parent b192c8a commit fcf8184
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
11 changes: 0 additions & 11 deletions python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,6 @@ def build_call_if_is_builtin(ctx, node, args, keywords):

if id(func) in replace_func:
node.ptr = replace_func[id(func)](*args, **keywords)
if func is min or func is max:
name = "min" if func is min else "max"
warnings.warn_explicit(
f'Calling builtin function "{name}" in Taichi scope is deprecated, '
f"and it will be removed in Taichi v1.6.0."
f'Please use "ti.{name}" instead.',
DeprecationWarning,
ctx.file,
node.lineno + ctx.lineno_offset,
module="taichi",
)
return True
return False

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 @@ -83,21 +83,6 @@ def test_deprecate_rwtexture_ndim():
ti.graph.Arg(ti.graph.ArgKind.RWTEXTURE, "x", shape=(128, 128), fmt=ti.Format.r32f)


@test_utils.test()
def test_deprecate_builtin_min_max():
with pytest.warns(
DeprecationWarning,
match='Calling builtin function "max" in Taichi scope is deprecated, '
"and it will be removed in Taichi v1.6.0.",
):

@ti.kernel
def func():
max(1, 2)

func()


@test_utils.test()
def test_deprecate_is_is_not():
with pytest.warns(
Expand Down
4 changes: 1 addition & 3 deletions tests/python/test_native_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def func():
y[i] = N - i
z[i] = i - 2 if i % 2 else i + 2

with pytest.warns(DeprecationWarning, match="Calling builtin function") as records:
func()
assert len(records) > 0
func()

assert np.allclose(
minimum.to_numpy(),
Expand Down

0 comments on commit fcf8184

Please sign in to comment.