Skip to content

Commit

Permalink
[Lang] Deprecate ti.pyfunc (#4764)
Browse files Browse the repository at this point in the history
* [Lang] Deprecate ti.pyfunc

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lin-hitonami and pre-commit-ci[bot] authored Apr 12, 2022
1 parent a63c108 commit ad2625f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python/taichi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@
}

__customized_deprecations__ = {
'parallelize': ('loop_config(parallelize=...)', 'lang.misc._parallelize'),
'serialize': ('loop_config(serialize=True)', 'lang.misc._serialize'),
'block_dim': ('loop_config(block_dim=...)', 'lang.misc._block_dim')
'parallelize': ('Please use ti.loop_config(parallelize=...) instead.',
'lang.misc._parallelize'),
'serialize': ('Please use ti.loop_config(serialize=True) instead.',
'lang.misc._serialize'),
'block_dim': ('Please use ti.loop_config(block_dim=...) instead.',
'lang.misc._block_dim'),
'pyfunc': ('Please avoid using it.', 'lang.kernel_impl.pyfunc')
}

if sys.version_info.minor < 7:
Expand All @@ -71,9 +75,8 @@ def __getattr__(attr):
return locals()[attr]
if attr in __customized_deprecations__:
msg, fun = __customized_deprecations__[attr]
warnings.warn(
f'ti.{attr} is deprecated. Please use ti.{msg} instead.',
DeprecationWarning)
warnings.warn(f'ti.{attr} is deprecated. {msg}',
DeprecationWarning)
exec(f'{attr} = {fun}')
return locals()[attr]
raise AttributeError(f"module '{__name__}' has no attribute '{attr}'")
Expand Down

0 comments on commit ad2625f

Please sign in to comment.