docs.taichi.graphics icon indicating copy to clipboard operation
docs.taichi.graphics copied to clipboard

The code snippet about ti.Vector is not working

Open cooperliu101 opened this issue 3 years ago • 6 comments

I find that the below code is not working. the taichi version is 1.1.2. The code is placed at field.md

f = ti.Vector(ti.f32, n=2).field(shape=(1,2,3))

Is this the old syntax?

cooperliu101 avatar Sep 13 '22 08:09 cooperliu101

@neozhaoliang Please could you take a look?

writinwaters avatar Sep 15 '22 07:09 writinwaters

@cooperliu101 The function ti.Vector requires an input array, it does not support the syntax ti.Vector(dtype, n).

neozhaoliang avatar Sep 15 '22 07:09 neozhaoliang

The code is placed at field.md we should fix the doc

cooperliu101 avatar Sep 23 '22 01:09 cooperliu101

@cooperliu101 Could please add the link to that line?

neozhaoliang avatar Sep 23 '22 01:09 neozhaoliang

The 1.1.3 version doc have replaced with new code contents.

The below link is the old version. https://github.com/taichi-dev/docs.taichi.graphics/blob/master/website/versioned_docs/version-v1.1.2/lang/articles/basic/field.md#declaration-1

cooperliu101 avatar Sep 25 '22 03:09 cooperliu101

Thanks. The line below in the link is wrong and we have fixed it in v1.1.3:

# Declare a 1x2x3 vector field whose vector dimension is n=2
f = ti.Vector(ti.f32, n=2).field(shape=(1,2,3))

The correct syntax isti.Vector.field, not ti.Vector().field().

neozhaoliang avatar Sep 25 '22 04:09 neozhaoliang