You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was defining custom @ti.data_oriented and encountered this problem. Here is my code
@ti.data_oriented
class Scene:
def __init__(self, dt):
# spheres
self.num_sphere = ti.field(dtype=ti.i32, shape=())
self.spheres = Sphere.field(shape=(100,))
# particles in local coordinates
self.num_pt = ti.field(dtype=ti.i32, shape=())
self.particles = ti.Vector.field(2, shape=(10000), dtype=ti.f32)
self.indecies = ti.field(dtype=ti.i32, shape=(10000))
self.init_sphere(self, vec2(0,0), 0.5)
def init_sphere(self, o, r, R=vec2(1,0), v=vec2(0,0), ω=0, m=1, I=None, size=None):
"""Initialize a sphere"""
self.spheres[self.num_sphere[None]].init(o, r, R, v, ω, m, I, size)
self.num_sphere[None] += 1
This is what I got
File "c:\Zichen\Cornell\spring2023\CS5643\SimSDF\scene.py", line 24, in f
self.init_sphere(self, vec2(0,0), 0.5)
File "c:\Zichen\Cornell\spring2023\CS5643\SimSDF\scene.py", line 30, in init_sphere
self.spheres.o[0] = o
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\util.py", line 311, in wrapped
return func(*args, **kwargs)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\matrix.py", line 1404, in setitem
self[key]._set_entries(value)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\util.py", line 311, in wrapped
return func(*args, **kwargs)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\matrix.py", line 453, in _set_entries
value = list(value)
TypeError: 'Scene' object is not iterable
However, I can self.spheres[self.num_sphere[None]].init(o, r, R, v, ω, m, I, size) with no problem directly in init or in my main.py. So I am not sure why this is happening.
The text was updated successfully, but these errors were encountered:
Hi,
I was defining custom @ti.data_oriented and encountered this problem. Here is my code
@ti.data_oriented
class Scene:
This is what I got
File "c:\Zichen\Cornell\spring2023\CS5643\SimSDF\scene.py", line 24, in f
self.init_sphere(self, vec2(0,0), 0.5)
File "c:\Zichen\Cornell\spring2023\CS5643\SimSDF\scene.py", line 30, in init_sphere
self.spheres.o[0] = o
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\util.py", line 311, in wrapped
return func(*args, **kwargs)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\matrix.py", line 1404, in setitem
self[key]._set_entries(value)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\util.py", line 311, in wrapped
return func(*args, **kwargs)
File "C:\Users\ziche\anaconda3\envs\sim-sdf\lib\site-packages\taichi\lang\matrix.py", line 453, in _set_entries
value = list(value)
TypeError: 'Scene' object is not iterable
However, I can self.spheres[self.num_sphere[None]].init(o, r, R, v, ω, m, I, size) with no problem directly in init or in my main.py. So I am not sure why this is happening.
The text was updated successfully, but these errors were encountered: