Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 10, 2023
1 parent 5014d76 commit 2fbaea5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
9 changes: 3 additions & 6 deletions python/taichi/_snode/fields_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def pointer(self, indices: Union[Sequence[_Axis], _Axis],
"""Same as :func:`taichi.lang.snode.SNode.pointer`"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Pointer SNode on metal backend is deprecated and removed."
)
"Pointer SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.pointer(indices, dimensions)
Expand All @@ -93,8 +92,7 @@ def dynamic(self,
"""Same as :func:`taichi.lang.snode.SNode.dynamic`"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Dynamic SNode on metal backend is deprecated and removed."
)
"Dynamic SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.dynamic(index, dimension, chunk_size)
Expand All @@ -104,8 +102,7 @@ def bitmasked(self, indices: Union[Sequence[_Axis], _Axis],
"""Same as :func:`taichi.lang.snode.SNode.bitmasked`"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Bitmasked SNode on metal backend is deprecated and removed."
)
"Bitmasked SNode on metal backend is deprecated and removed.")
self._check_not_finalized()
self.empty = False
return self.root.bitmasked(indices, dimensions)
Expand Down
11 changes: 4 additions & 7 deletions python/taichi/lang/snode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from taichi._lib import core as _ti_core
from taichi.lang import expr, impl, matrix
from taichi.lang.exception import TaichiRuntimeError
from taichi.lang.field import BitpackedFields, Field
from taichi.lang.util import get_traceback
from taichi.lang.exception import TaichiRuntimeError


class SNode:
Expand Down Expand Up @@ -50,8 +50,7 @@ def pointer(self, axes, dimensions):
"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Pointer SNode on metal backend is deprecated and removed."
)
"Pointer SNode on metal backend is deprecated and removed.")
if isinstance(dimensions, numbers.Number):
dimensions = [dimensions] * len(axes)
return SNode(
Expand Down Expand Up @@ -81,8 +80,7 @@ def dynamic(self, axis, dimension, chunk_size=None):
"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Dynamic SNode on metal backend is deprecated and removed."
)
"Dynamic SNode on metal backend is deprecated and removed.")
assert len(axis) == 1
if chunk_size is None:
chunk_size = dimension
Expand All @@ -102,8 +100,7 @@ def bitmasked(self, axes, dimensions):
"""
if impl.current_cfg().arch == _ti_core.metal:
raise TaichiRuntimeError(
"Bitmasked SNode on metal backend is deprecated and removed."
)
"Bitmasked SNode on metal backend is deprecated and removed.")
if isinstance(dimensions, numbers.Number):
dimensions = [dimensions] * len(axes)
return SNode(
Expand Down
12 changes: 4 additions & 8 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,23 @@ def test_deprecate_element_shape_ndarray_arg():
ndim=1,
element_shape=(1, ))


# Remove this before v1.5.0
@test_utils.test(arch=ti.metal)
def test_deprecate_metal_sparse():
with pytest.raises(
ti.TaichiRuntimeError,
match=
"Pointer SNode on metal backend is deprecated and removed."
):
match="Pointer SNode on metal backend is deprecated and removed."):
a = ti.root.pointer(ti.i, 10)
with pytest.raises(
ti.TaichiRuntimeError,
match=
"Bitmasked SNode on metal backend is deprecated and removed."
match="Bitmasked SNode on metal backend is deprecated and removed."
):
b = a.bitmasked(ti.j, 10)

with pytest.raises(
ti.TaichiRuntimeError,
match=
"Dynamic SNode on metal backend is deprecated and removed."
):
match="Dynamic SNode on metal backend is deprecated and removed."):
ti.root.dynamic(ti.i, 10)


Expand Down

0 comments on commit 2fbaea5

Please sign in to comment.