Concisely describe the proposed feature
As @archibate mentioned before, I want to improve the docs for these 2 points:
ti.imwrite, note that ti.f32 can also be used to export images.ti.Matrix and ti.Vector with ti.imwrite(), so that our user's mind won't be restricted in ti.varBesides, I also find that in our newest release, ti.imwrite is changed to:
In these codes above, we first assert:
assert len(img.shape) in [2, 3], "Image must be either RGB/RGBA or greyscale"
But If the length of image.shape is really two, our second assertation will fail by out-of-bounds accessing for img.shape:
assert img.shape[2] in [1, 3, 4], "Image must be either RGB/RGBA or greyscale"
Maybe I can help to fix it.
A clear and concise description of what you want.
I will add some more examples and explanations in export_result.rst and gui.rst
Maybe I can help to do some minor revision in ti.imwrite
Describe the solution you'd like (if any)
in image.py, change the code so that we only have the second assertation (mentioned above) when len(img.shape) == 3.
Additional comments
Nothing more.
My fault, thank for pointing out! Maybe we should move the assert to L26 and change shape[2] to comp? Sorry about not testing before merge... I think the ultimate solution is to add a test for this, there's already one in test_image_io.py, but not strong enough.
Thanks a lot for such a quick reply!
This bug is sooo secret.If I am not doing some test in it, I can not find it as well.
I agree! A test should be added in case we together introduce something risky again. Do you think it's proper for me to create a Draft PR and show my modified and test code in it?
Oh! That would be great, but I've already added a test now, would you mind review it?
Amazing efficiency! Certainly! So that I can only focus on the doc :D
Most helpful comment
My fault, thank for pointing out! Maybe we should move the assert to L26 and change
shape[2]tocomp? Sorry about not testing before merge... I think the ultimate solution is to add a test for this, there's already one intest_image_io.py, but not strong enough.