-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Syntax for multidimensional arrays #33697
Syntax for multidimensional arrays #33697
Conversation
You appear to have introduced whitespace changes on every line. Did you perhaps edit the files on Windows in an editor that uses |
(downside of #32781 is that problem isn't caught locally anymore) |
Oops, somehow triggered Atom to switch from LF to CRLF in those files. Fixed. |
Saw there was a failing ParseError test because I forgot to restore a check and error message. Should be fixed. |
Just did some quick performance checks Allocated 10,000 times in a for loop inside a function, minimum observed time over several trials:
All times comparable. 1d and 2d arrays identical allocations. Not sure why cat itself has more overhead in my build. It doesn't seem to replicate in 1.2.0, 1.3.0-rc4, or 1.4.0-DEV. Some difference between the Windows build of Julia (what I use normally) and the Linux build (what I'm building in)? |
Just added inline printing of arrays, to complete the fix for #30467. Wasn't as hard as I thought. Thinking more about the 34-39x allocation overhead of the cat() approach, thought about reshape being more performant, and it appears so, only a 2x allocation overhead.
Which leads me to wonder why cat() has such a high overhead? Using reshape() from the parser would potentially make parsing easier, but perhaps there are things that can be done to improve cat()? |
I fixed two bugs caught thanks to failing tests:
|
Triage likes this, but we think there should be a release with a deprecation warning for using multiple semicolons. @Keno also has an alternate proposal to use |
An alternative I proposed on the triage call: Have
vs
in this PR. For lower dimensions, in my proposal
Anyway, food for thought. |
Of course a variant on my proposal that is even more similar to this proposal is to still use the multiple semicolons to concat in the |
That seems at odds with what the current single semicolon syntax does, i.e. always concatenate in the second dimension. |
yes, that's why I said |
In either case, we should do the change to reserve this syntax with a warning right away. |
Interesting idea @Keno. I appreciate the benefits of your proposal and for my own uses it'd be just as suitable. And perhaps they could be combined as you suggest. FTR, I'd consider With respect to a ten-dimensional cat, I figure at that point it'd be more readable to fall back to |
I'm not sure we can change |
I also don't think we want to change it. It's consistent with this PR. The real problem is that |
27fdfd8
to
80ce4bf
Compare
I tried to rebase onto the current master branch but something screwed up. Don't know if I did something or if the current master is iffy. Is there a way to tell where the error is from or advice on the best way to reset the branch? |
I believe your rebase went wrong, since it includes many commits that are irrelevant to this PR.
Hope it helps! |
a529408
to
26e2f26
Compare
Ah, perfect @Liozou, thank you! |
Glad I could help! |
Windows editor turning new lines into |
@StefanKarpinski - Yeah, it's bitten me a few times. I think I've sorted it out. Just added typed_ncat, so now this is also valid:
I'm looking at tests for the parser, and I'm not certain from looking what I should be testing for or where they should go in the syntax.jl file. They seem to be organized by issue rather than type? EDIT: Did just add documentation and doctests, if that covers it. |
This comment has been minimized.
This comment has been minimized.
4d7f3a7
to
e38ba55
Compare
I think everything has been addressed, now just to get to green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the doctest failure, but otherwise LGTM!
Okay, looks like we got it! Getting the operations on the intermediate data structure just right is trickier than it seems like it should be.
|
Actually, I can easily make it so that it's one side of the linebreak or the other but not both. Then someone could, if they wanted, do something like:
In fact, already done. |
OK, let's try this! |
This will get a different meaning in 1.7 (ref JuliaLang/julia#33697)
This will get a different meaning in 1.7. (ref JuliaLang/julia#33697)
Should we disallow spaces between semicolons as in |
Oh interesting, yes, I agree we should do that. Because I had to check: the currently implemented mechanism treats |
That is a good idea. Implemented in #40903 |
Co-authored-by: Matt Bauman <mbauman@gmail.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
Co-authored-by: Matt Bauman <mbauman@gmail.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
Use multiple semicolons to denote >2 dimensions in an inline N-dimensional array specification.
Summary of all changes in PR and how it works: #33697 (comment)
Breaking changes: Extra semicolons in matrix expression currently ignored. However, use is likely to be rare and unintentional.
#37168 adds deprecation warning for this.That PR was merged.Related work:
Any
argument)Extend terminal semicolons to vector expression e.g.Removed[1,2,3;;;]
print(rand(Int8, 2,2,2))
(temporary)I did this largely as an exercise for myself, to partly address #30467 .
Unsure how much I can do on the rest but if I get pointers I may be able to. If this approach is deemed worth continuing.