Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Error] Update deprecation warning of the graph arguments #7965

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions python/taichi/graph/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def _deprecate_arg_args(kwargs: Dict[str, Any]):
if tag == ArgKind.SCALAR:
if "element_shape" in kwargs:
warnings.warn(
"The element_shape argument for scalar will be deprecated in v1.6.0. You can remove them safely.",
"The element_shape argument for scalar is deprecated in v1.6.0, and will be removed in v1.7.0. "
"Please remove them.",
DeprecationWarning,
)
del kwargs["element_shape"]
Expand All @@ -131,7 +132,8 @@ def _deprecate_arg_args(kwargs: Dict[str, Any]):
kwargs["element_shape"] = ()
else:
warnings.warn(
"The element_shape argument for ndarray will be deprecated in v1.6.0, use vector or matrix data type instead.",
"The element_shape argument for ndarray is deprecated in v1.6.0, and it will be removed in v1.7.0. "
"Please use vector or matrix data type instead.",
DeprecationWarning,
)
if "dtype" not in kwargs:
Expand All @@ -149,7 +151,8 @@ def _deprecate_arg_args(kwargs: Dict[str, Any]):

if "shape" in kwargs:
warnings.warn(
"The shape argument for texture will be deprecated in v1.6.0, use ndim instead. (Note that you no longer need the exact texture size.)",
"The shape argument for texture is deprecated in v1.6.0, and it will be removed in v1.7.0. "
"Please use ndim instead. (Note that you no longer need the exact texture size.)",
DeprecationWarning,
)
kwargs["ndim"] = len(kwargs["shape"])
Expand All @@ -164,12 +167,14 @@ def _deprecate_arg_args(kwargs: Dict[str, Any]):
fmt = TY_CH2FORMAT[(kwargs["channel_format"], kwargs["num_channels"])]
kwargs["fmt"] = fmt
warnings.warn(
"The channel_format and num_channels arguments for texture will be deprecated in v1.6.0, use fmt instead.",
"The channel_format and num_channels arguments for texture are deprecated in v1.6.0, "
"and they will be removed in v1.7.0. Please use fmt instead.",
DeprecationWarning,
)
else:
warnings.warn(
"The channel_format and num_channels arguments are no longer required for non-RW textures since v1.6.0, you can remove them safely.",
"The channel_format and num_channels arguments are no longer required for non-RW textures "
"since v1.6.0, and they will be removed in v1.7.0. Please remove them.",
DeprecationWarning,
)
if "channel_format" in kwargs:
Expand Down
18 changes: 12 additions & 6 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
def test_deprecate_element_shape_scalar():
with pytest.warns(
DeprecationWarning,
match="The element_shape argument for scalar will be deprecated in v1.6.0. You can remove them safely.",
match="The element_shape argument for scalar is deprecated in v1.6.0, and will be removed in v1.7.0. "
"Please remove them.",
):
sym_x = ti.graph.Arg(ti.graph.ArgKind.SCALAR, "x", dtype=ti.f32, element_shape=())

Expand All @@ -21,7 +22,8 @@ def test_deprecate_element_shape_scalar():
def test_deprecate_element_shape_ndarray_arg():
with pytest.warns(
DeprecationWarning,
match="The element_shape argument for ndarray will be deprecated in v1.6.0, use vector or matrix data type instead.",
match="The element_shape argument for ndarray is deprecated in v1.6.0, and it will be removed in v1.7.0. "
"Please use vector or matrix data type instead.",
):
ti.graph.Arg(ti.graph.ArgKind.NDARRAY, "x", ti.f32, ndim=1, element_shape=(1,))

Expand All @@ -30,7 +32,8 @@ def test_deprecate_element_shape_ndarray_arg():
def test_deprecate_texture_channel_format_num_channels():
with pytest.warns(
DeprecationWarning,
match="The channel_format and num_channels arguments are no longer required for non-RW textures since v1.6.0, you can remove them safely.",
match="The channel_format and num_channels arguments are no longer required for non-RW textures "
"since v1.6.0, and they will be removed in v1.7.0. Please remove them.",
):
ti.graph.Arg(ti.graph.ArgKind.TEXTURE, "x", ndim=2, channel_format=ti.f32, num_channels=1)

Expand All @@ -39,7 +42,8 @@ def test_deprecate_texture_channel_format_num_channels():
def test_deprecate_rwtexture_channel_format_num_channels():
with pytest.warns(
DeprecationWarning,
match="The channel_format and num_channels arguments for texture will be deprecated in v1.6.0, use fmt instead.",
match="The channel_format and num_channels arguments for texture are deprecated in v1.6.0, "
"and they will be removed in v1.7.0. Please use fmt instead.",
):
ti.graph.Arg(
ti.graph.ArgKind.RWTEXTURE,
Expand All @@ -54,7 +58,8 @@ def test_deprecate_rwtexture_channel_format_num_channels():
def test_deprecate_texture_ndim():
with pytest.warns(
DeprecationWarning,
match=r"The shape argument for texture will be deprecated in v1.6.0, use ndim instead. \(Note that you no longer need the exact texture size.\)",
match=r"The shape argument for texture is deprecated in v1.6.0, and it will be removed in v1.7.0. "
r"Please use ndim instead. \(Note that you no longer need the exact texture size.\)",
):
ti.graph.Arg(ti.graph.ArgKind.TEXTURE, "x", shape=(128, 128), channel_format=ti.f32)

Expand All @@ -63,7 +68,8 @@ def test_deprecate_texture_ndim():
def test_deprecate_rwtexture_ndim():
with pytest.warns(
DeprecationWarning,
match=r"The shape argument for texture will be deprecated in v1.6.0, use ndim instead. \(Note that you no longer need the exact texture size.\)",
match=r"The shape argument for texture is deprecated in v1.6.0, and it will be removed in v1.7.0. "
r"Please use ndim instead. \(Note that you no longer need the exact texture size.\)",
):
ti.graph.Arg(ti.graph.ArgKind.RWTEXTURE, "x", shape=(128, 128), fmt=ti.Format.r32f)

Expand Down