Skip to content

Commit

Permalink
[Lang] Cancel deprecating native min/max (#7928)
Browse files Browse the repository at this point in the history
Issue: #

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at fcf8184</samp>

Remove the deprecation warning for using the builtin `min` and `max`
functions in Taichi scope. Update the related test cases to match the
new behavior.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at fcf8184</samp>

* Remove the deprecation warning for using the builtin `min` and `max`
functions in Taichi scope
([link](https://github.com/taichi-dev/taichi/pull/7928/files?diff=unified&w=0#diff-3e22417ffade4af0564893b98dc5101d714b8ba6fd4423ab5bc5129e360fee8fL437-L447))
* Update the test cases to reflect the new behavior of the AST
transformer
([link](https://github.com/taichi-dev/taichi/pull/7928/files?diff=unified&w=0#diff-8981be068a363e39524dc2e29d28d4c13a097d0037fc3a1176b249ce5bf35ef8L87-L101),
[link](https://github.com/taichi-dev/taichi/pull/7928/files?diff=unified&w=0#diff-cc8e7da3222177c1a6a058d133c0b6ea736f6a1fc34a958bc4bc6fe7ea9462d0L75-R75))
  • Loading branch information
lin-hitonami authored May 6, 2023
1 parent 2e071fc commit 0599ecc
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 0599ecc

Please sign in to comment.