Skip to content

Conversation

@simonbyrne
Copy link
Member

@simonbyrne simonbyrne commented Feb 9, 2019

The current matrix syntax has no elegant way for representing a matrix of a single column. Currently show (and repr) print elements separated by semicolons, which is actually parsed as a vector, e.g.

julia> x = [i for i=1:3, j=1:1]
3×1 Array{Int64,2}:
 1
 2
 3

julia> repr(x)
"[1; 2; 3]"

julia> eval(Meta.parse(repr(x)))
3-element Array{Int64,1}:
 1
 2
 3

This changes it so that it is represented as permutedims of a single row matrix:

julia> repr(x)
"permutedims([1 2 3])"

It's not the most elegant solution: feedback appreciated.

@simonbyrne simonbyrne added the display and printing Aesthetics and correctness of printed representations of objects. label Feb 9, 2019
@simonbyrne
Copy link
Member Author

Some other options:

  • define a method Matrix(x::Vector), and print it as Matrix([1,2,3])
  • define a function mat (analogous to vec), and print it as mat([1,2,3]).

@martinholters
Copy link
Member

...or print as hcat([1,2,3]).

@simonbyrne
Copy link
Member Author

hcat does look like the simplest option here.

@simonbyrne simonbyrne force-pushed the sb/single-column-matrix branch from 1b88b18 to c02927b Compare April 11, 2019 17:57
@oxinabox
Copy link
Contributor

Re the suggestion of mat, I like that one
I made (and abandonned) a PR for that a while ago
#23790

@simonbyrne
Copy link
Member Author

Fixed by #33697

@simonbyrne simonbyrne closed this Feb 13, 2023
@simonbyrne simonbyrne deleted the sb/single-column-matrix branch February 13, 2023 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display and printing Aesthetics and correctness of printed representations of objects.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants