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

Ndarray type annotations & error message refinement #6572

Open
2 of 4 tasks
ailzhang opened this issue Nov 10, 2022 · 1 comment
Open
2 of 4 tasks

Ndarray type annotations & error message refinement #6572

ailzhang opened this issue Nov 10, 2022 · 1 comment
Assignees
Labels
P0 This issue is urgent to be solved and has highest priority

Comments

@ailzhang
Copy link
Contributor

ailzhang commented Nov 10, 2022

We had a discussion about refining ndarray definition and type annotation in #4085 earlier this year and it's now a hard blocker if we want to properly release ndarray to users. Based on the discussions with @k-ye and @strongoier , we'll list out the desired APIs as well as some examples of bad error messages we wanna fix here.

Type annotation

Currently ti.types.ndarray() can take in dtype/element_dim/element_shape/field_dim as optional arguments, we'd like to:

  • Rename field_dim to ndim (following numpy etc)
  • Get rid of element_dim and element_shape in the type annotation

And the desired ndarray type annotation API may only takes two optional argument dtype and ndim, which looks like below:

arr: ti.types.ndarray()
arr: ti.types.ndarray(dtype=ti.f32)
arr: ti.types.ndarray(dtype=ti.math.vec3)
arr: ti.types.ndarray(ndim=2)
arr: ti.types.ndarray(dtype=ti.f32, ndim=2)

Error message

Currently we've got a lot to improve in terms of telling users what's wrong with their ndarray usage, listing a few examples below:

A running demo can be found at https://gist.github.com/ailzhang/d207a53c26720cccb7e7c5a9687009c2

tp_ivec3 = ti.types.vector(3, ti.i32)
tp_ivec2 = ti.types.vector(2, ti.i32)
tp_vec3 = ti.types.vector(3, ti.f32)

x = ti.ndarray(ti.f32, shape=(12, 13))
y = ti.ndarray(tp_ivec3, shape=(12,4))
z = ti.ndarray(ti.i32, shape=(12, 12))
m = ti.ndarray(tp_ivec2, shape=(2, 3))
n = ti.ndarray(ti.f32, shape=(12,))
k = ti.ndarray(tp_vec3, shape=(12,))

@ti.kernel
def test1(arr: ti.types.ndarray()):
    for I in ti.grouped(arr):
        arr[I] = 1

test1(x)
print(x.to_numpy())

# Case 1: The following currently errors out since the kernel implicitly assumes scalar element. We need better error message to users.
#test1(y)

@ti.kernel
def test2(arr: ti.types.ndarray(dtype=ti.f32)):
    for I in ti.grouped(arr):
        arr[I] = 2.0

test2(x)
print(x.to_numpy())

# Case 2: This works, but it should error out since it doesn't match type annotation. 
test2(z)
print(z.to_numpy())

# Case 3: this errors out, but currently error message should be mismatch dtype
# test2(y)

@ti.kernel
def test3(arr: ti.types.ndarray(dtype=tp_ivec3)):
    for I in ti.grouped(arr):
        arr[I] = [0, 1, 2]

test3(y)
print(y.to_numpy())

# Case 4: this errors out, but message should be mismatched dtype
# test3(m)

# Case 5: This should have errored out but didn't
# test3(k)

@ti.kernel
def test4(arr: ti.types.ndarray(dtype=tp_ivec3)):
    for I in ti.grouped(arr):
        arr[I] = [1, 2]

# Case 6: test4 is just bad kernel. It should just error out in compilation saying [1, 2] doesn't match ivec3 dtype
# test4(y)

@ti.kernel
def test5(arr: ti.types.ndarray(field_dim=1)):
    for i, j in arr:
        arr[i, j] = 0

# Case 7: test5 is just bad kernel, this should error out in compilation saying `for i, j in arr` doesn't match annotated field_dim=1 
# test5(x)

@ti.kernel
def test6(arr: ti.types.ndarray(field_dim=2)):
    for i, j in arr:
        arr[i, j] = 6

# Works as expected
test6(x)
print(x.to_numpy())

# Case 8: this errors out but message can be given ivec2 but arr requires scalar dtype. 
# test6(m)

# Case 9: this errors out but message can be give field_dim=1 but arr requires field_dim=2
# test6(n)

Note we'll need similar improvement when compiling kernels in AOT mode as well but those should be simple after the aforementioned issues are resolved.

Additional Cleanup

  • We were not consistent in enforcing the order of arguments when defining a type or ndarray initialization, for example:
vec3 = ti.types.vector(3, ti.f32)
arr_ty = ti.types.ndarray(dtype=ti.f32, ndim=2)
arr = ti.ndarray(dtype=ti.f32, shape=(3, 3)) 

Notice the swap of dtype and shape arguments here? We'd actually like to unify to dtype first order for all of them, which involves adding some deprecation warnings.

  • In addition, we should support vec/matrix dtype in ti.field() and deprecate ti.Vector.field() and ti.Matrix.field() APIs.
@ailzhang ailzhang added the P0 This issue is urgent to be solved and has highest priority label Nov 10, 2022
@ailzhang ailzhang added this to the v1.3.0 milestone Nov 10, 2022
@turbo0628 turbo0628 self-assigned this Nov 10, 2022
turbo0628 added a commit that referenced this issue Nov 17, 2022
Issue: #6572

Changes:
* Replace all the element_dim and element_shape arguments with matrix
types in ndarray unit tests.
* [BREAK CHANGE] raises a TypeError when external array doesn't math
matrix element type shape. Before this PR we don't check the consistency
and silently trigger recompilation.
* Throw a warning if user specifies element_dim and element_shape

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
turbo0628 added a commit that referenced this issue Nov 18, 2022
Issue: #6572 

* Re-open #6620 which unexpectedly broke difftaichi and other user
codes.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
turbo0628 added a commit that referenced this issue Nov 21, 2022
#6665)

Issue: #6572 

Changes:
* Add deprecation warning when `element_shape` and `element_dim` are
specified.
* Internally remove `element_shape` and `element_dim` inside the type
annotation. Added a helper function to create respective MatrixType in
dtype for legacy code.
* Add deprecation test.
* Update docstring.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ailing  <ailzhang@users.noreply.github.com>
turbo0628 added a commit that referenced this issue Nov 22, 2022
Issue: #6572 

* Deprecate `field_dim` in ndarray type annotation, replace with `ndim`.
* Change tests accordingly. Examples are left unchanged.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@PENGUINLIONG PENGUINLIONG modified the milestones: v1.3.0, v1.4.0 Nov 25, 2022
@lin-hitonami lin-hitonami modified the milestones: v1.4.0, v1.5.0 Jan 5, 2023
turbo0628 added a commit that referenced this issue Jan 10, 2023
)

Issue: #6572 

* Fix using dtype for symbolic args in AOT usages
* Cleanup all the usages of `field_dim` and `element_shape` in examples and tests
@turbo0628
Copy link
Member

Yet another confusing error message

import taichi as ti
import numpy as np

ti.init(arch=ti.gpu)

@ti.kernel
def add_num(num : ti.f32, arr : ti.types.ndarray(dtype=ti.math.mat3, ndim=2)):
    for i in ti.grouped(arr):
        arr[i] = arr[i] + num

arr_np = np.ones((2,2,3,3), dtype=np.float32)
arr_ti = ti.ndarray(dtype=ti.math.vec3, shape=(2, 2))
arr_ti.from_numpy(arr_np)
add_num(1.12, arr_ti)
print(arr_ti.to_numpy())
[Taichi] version 1.5.0, llvm 15.0.5, commit 6f8e0edb, osx, python 3.9.12
[Taichi] Starting on arch=metal
Traceback (most recent call last):
  File "/Users/lanhaidong/example_vec.py", line 13, in <module>
    arr_ti.from_numpy(arr_np)
  File "/Users/lanhaidong/work/taichi_fork/python/taichi/lang/util.py", line 310, in wrapped
    return func(*args, **kwargs)
  File "/Users/lanhaidong/work/taichi_fork/python/taichi/lang/matrix.py", line 1809, in from_numpy
    self._ndarray_matrix_from_numpy(arr, as_vector=1)
  File "/Users/lanhaidong/work/taichi_fork/python/taichi/lang/util.py", line 310, in wrapped
    return func(*args, **kwargs)
  File "/Users/lanhaidong/work/taichi_fork/python/taichi/lang/_ndarray.py", line 139, in _ndarray_matrix_from_numpy
    raise ValueError(
ValueError: Mismatch shape: (2, 2) expected, but (2, 2, 3, 3) provided

The "expected shape" hint doesn't include the element shape, so it's very confusing.

lin-hitonami pushed a commit to lin-hitonami/taichi that referenced this issue Jan 11, 2023
…ichi-dev#7100)

Issue: taichi-dev#6572 

* Fix using dtype for symbolic args in AOT usages
* Cleanup all the usages of `field_dim` and `element_shape` in examples and tests
lin-hitonami pushed a commit to lin-hitonami/taichi that referenced this issue Jan 12, 2023
…ichi-dev#7100)

Issue: taichi-dev#6572 

* Fix using dtype for symbolic args in AOT usages
* Cleanup all the usages of `field_dim` and `element_shape` in examples and tests
lin-hitonami pushed a commit that referenced this issue Jan 12, 2023
Issue: #6572 

* Check external ndarray total dim against type annotation
* Error out when element shape mismatch
* Refine error messages

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
lin-hitonami pushed a commit that referenced this issue Jan 13, 2023
Issue: #6572 

* Check external ndarray total dim against type annotation
* Error out when element shape mismatch
* Refine error messages

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@turbo0628 turbo0628 modified the milestones: v1.5.0, v1.6.0 Mar 9, 2023
@ailzhang ailzhang self-assigned this Apr 3, 2023
ailzhang added a commit that referenced this issue Apr 10, 2023
Issue: #6572 

For backward compatibility reason we cannot change any positional arg
and kwargs in `ti.field` but we this PR simply added support for vector
and matrix dtypes.

Whether to deprecate `ti.Vector.field` and `ti.Matrix.field` can be a
separate decision.

Testing: to avoid massive duplicated tests I just replaced all
`ti.Vector.field/ti.Matrix.field` in `test_fields.py` to use this
unified API. There're plenty of other files that use the old APIs so
this should be fine for now.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

Unified the creation of vector and matrix fields with a single `field`
function in `taichi.lang.impl`. Updated the tests in `test_field.py` to
use the new function and removed the deprecated ones. This improves the
consistency and readability of the field API.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

* Rename and redefine `field` function to handle vector and matrix types
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L19-R19),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L698-R704),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Update `field` function docstring and examples in
`python/taichi/lang/impl.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Replace `Vector.field` and `Matrix.field` with `field` function in
`tests/python/test_field.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L38-R39),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L55-R57),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L135-R137),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L141-R144),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L171-R174),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L177-R181),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L197-R203),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L207-R212),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L215-R221),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L295-R300),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L302-R308))
ailzhang added a commit to ailzhang/taichi that referenced this issue Apr 12, 2023
Issue: taichi-dev#6572 

For backward compatibility reason we cannot change any positional arg
and kwargs in `ti.field` but we this PR simply added support for vector
and matrix dtypes.

Whether to deprecate `ti.Vector.field` and `ti.Matrix.field` can be a
separate decision.

Testing: to avoid massive duplicated tests I just replaced all
`ti.Vector.field/ti.Matrix.field` in `test_fields.py` to use this
unified API. There're plenty of other files that use the old APIs so
this should be fine for now.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

Unified the creation of vector and matrix fields with a single `field`
function in `taichi.lang.impl`. Updated the tests in `test_field.py` to
use the new function and removed the deprecated ones. This improves the
consistency and readability of the field API.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

* Rename and redefine `field` function to handle vector and matrix types
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L19-R19),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L698-R704),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Update `field` function docstring and examples in
`python/taichi/lang/impl.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Replace `Vector.field` and `Matrix.field` with `field` function in
`tests/python/test_field.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L38-R39),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L55-R57),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L135-R137),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L141-R144),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L171-R174),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L177-R181),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L197-R203),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L207-R212),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L215-R221),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L295-R300),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L302-R308))
ailzhang added a commit that referenced this issue May 10, 2023
…el (#7966)

Issue: #6572

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at d1aa92d</samp>

Add new tests and error handling for ndarray feature. Improve `__repr__`
method for `TensorType` and error message for `NdarrayType`.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at d1aa92d</samp>

* Add a string representation method for tensor types
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-78972e3ce6c462d977b9e713e447e8f3305899c8037a6992c37546aa0c4cb291L22-R25))
* Improve the error message for ndarray type validation
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-06e0109e9fa5071f7d364306981845d410fa17425db48001e3ba69337b47c152L127-R127))
* Add tests for ndarray type mismatch scenarios
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L6-R6),
[link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0R870-R910))
@feisuzhu feisuzhu modified the milestones: v1.6.0, v1.7.0 May 11, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
…i-dev#6620)

Issue: taichi-dev#6572

Changes:
* Replace all the element_dim and element_shape arguments with matrix
types in ndarray unit tests.
* [BREAK CHANGE] raises a TypeError when external array doesn't math
matrix element type shape. Before this PR we don't check the consistency
and silently trigger recompilation.
* Throw a warning if user specifies element_dim and element_shape

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: taichi-dev#6572 

* Re-open taichi-dev#6620 which unexpectedly broke difftaichi and other user
codes.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
taichi-dev#6665)

Issue: taichi-dev#6572 

Changes:
* Add deprecation warning when `element_shape` and `element_dim` are
specified.
* Internally remove `element_shape` and `element_dim` inside the type
annotation. Added a helper function to create respective MatrixType in
dtype for legacy code.
* Add deprecation test.
* Update docstring.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ailing  <ailzhang@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: taichi-dev#6572 

* Deprecate `field_dim` in ndarray type annotation, replace with `ndim`.
* Change tests accordingly. Examples are left unchanged.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
…ichi-dev#7100)

Issue: taichi-dev#6572 

* Fix using dtype for symbolic args in AOT usages
* Cleanup all the usages of `field_dim` and `element_shape` in examples and tests
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: taichi-dev#6572 

* Check external ndarray total dim against type annotation
* Error out when element shape mismatch
* Refine error messages

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: taichi-dev#6572 

For backward compatibility reason we cannot change any positional arg
and kwargs in `ti.field` but we this PR simply added support for vector
and matrix dtypes.

Whether to deprecate `ti.Vector.field` and `ti.Matrix.field` can be a
separate decision.

Testing: to avoid massive duplicated tests I just replaced all
`ti.Vector.field/ti.Matrix.field` in `test_fields.py` to use this
unified API. There're plenty of other files that use the old APIs so
this should be fine for now.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

Unified the creation of vector and matrix fields with a single `field`
function in `taichi.lang.impl`. Updated the tests in `test_field.py` to
use the new function and removed the deprecated ones. This improves the
consistency and readability of the field API.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

* Rename and redefine `field` function to handle vector and matrix types
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L19-R19),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L698-R704),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Update `field` function docstring and examples in
`python/taichi/lang/impl.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Replace `Vector.field` and `Matrix.field` with `field` function in
`tests/python/test_field.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L38-R39),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L55-R57),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L135-R137),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L141-R144),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L171-R174),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L177-R181),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L197-R203),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L207-R212),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L215-R221),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L295-R300),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L302-R308))
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
…el (taichi-dev#7966)

Issue: taichi-dev#6572

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at d1aa92d</samp>

Add new tests and error handling for ndarray feature. Improve `__repr__`
method for `TensorType` and error message for `NdarrayType`.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at d1aa92d</samp>

* Add a string representation method for tensor types
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-78972e3ce6c462d977b9e713e447e8f3305899c8037a6992c37546aa0c4cb291L22-R25))
* Improve the error message for ndarray type validation
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-06e0109e9fa5071f7d364306981845d410fa17425db48001e3ba69337b47c152L127-R127))
* Add tests for ndarray type mismatch scenarios
([link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L6-R6),
[link](https://github.com/taichi-dev/taichi/pull/7966/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0R870-R910))
@jim19930609 jim19930609 removed this from the v1.7.0 milestone Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 This issue is urgent to be solved and has highest priority
Projects
Status: In Progress
Development

No branches or pull requests

6 participants