-
Notifications
You must be signed in to change notification settings - Fork 103
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
a way to construct multidimensional array without rho? #117
Comments
No, there is not. It was a deliberate decision for simplicity. It could be changed but would be a fair bit of work. |
I see. Is there a recommendation or hack for constructing such arrays if such syntax doesn't exist? I was trying to do simple processing over an array like
yesterday for Advent of Code, but gave up since I couldn't get the input into ivy. |
The engine doesn't support them, so there is no way to inject them. |
Sometimes, vectors inside vector is obtained, looking flat at first sight:
.. So if these cannot be constructed literally, shouldn't the result be flat and/or "Everything in ivy can be placed into a vector" statement from the demo be corrected? UPDATE: the same result here considered an error |
In #117, @smasher164 observed that ,\1 2 3 generates 1 (1 2) (1 2 3) despite the claim that ivy does not support non-scalar elements. I looked into preventing them from ever appearing, but that was messy and slow as it requires a lot of post-construction checking of things. So I tried the other direction, and made them legal. That turned out to be much more straightforward than I thought, although there were a number of associated changes to make it work. Whenever the existing barriers were removed, the code must actually work. Significant changes and bug fixes: - Fixed a trivial bug in parse that did not allow indexed expressions in vectors, for example 1 2 x[3] 4 - Can now input compound elements of vectors: 1 (1 2) 3 - They must also be printable clearly, and for simplicity I made the output model the input, at least for these simple vector cases. - Indexed assignment needed some tweaks, including fixing an existing bug: The rhs was not copied, so aliasing could happen and it was easy to demostrate bad behavior. Added a Copy method to Value to clean this up. - Support matrices and vectors in OrderedCompare. - Update and extend the tests. Some failure tests now worked! I didn't touch the docs. Not clear a change is needed, although this might be worth a phrase somewhere, perhaps in the demo. Also simplify the method for printing matrices, which will make it easier to fix a layout issue: A multiline matrix as an element of an array or matrix results in ugly output. Relatively easy to fix, but to be a separate change. Update #117
As you can see from the commit above, you got what you wanted. I suspect there remain rough edges. I know that printing still needs work, but have a handle on that. I'll leave this issue open at least until that is resolved. Thanks for the prod. |
Make the columns and rows line up in a meaningful way when there is, for example, a 2d matrix in the middle of a vector. There are surely many cases this won't handle well, but they should be quite rare, such as a 5d matrix inside a vector. And for the common cases that might actually arise, the output is reasonable. Also add testdata/print.ivy to have a single place to write tests for this. There may be many as things evolve. The same treatment for matrices will come next, or soon at least. Update #117
Is there a way to construct a multidimensional array with regular data entry?
In Dyalog, you can just write
Thanks
The text was updated successfully, but these errors were encountered: