print_matrix is broken for SubArrays #3697

Closed
stevengj opened this Issue Jul 12, 2013 · 1 comment

Projects

None yet

2 participants

@stevengj
The Julia Language member

Running a = [1,2,3,4]; b = sub(a, 1:2) in the repl gives

2-element SubArray of 4-element Int64 Array:
 #undef
 #undef

The culprit seems to be somewhere in print_matrix (since print_matrix(STDOUT, b) gives the two #undefs).

@johnmyleswhite
The Julia Language member

I'd bet that the problem is that SubArray doesn't implement a matrix style getindex for vectors. Does a quick hack like getindex(s::SubArray, i::Integer, j::Integer) = getindex(s, i) restore printing something that's not #undef?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment