Skip to content
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

RFC: print Array{T,1} as Vector{T} and Array{T,2} as Matrix{T} #36032

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ julia> y = zeros(7);
julia> copyto!(y, x);

julia> y
7-element Array{Float64,1}:
7-element Vector{Float64}:
1.0
0.0
3.0
Expand Down Expand Up @@ -955,7 +955,7 @@ julia> tup = (1, 2, 3)
(1, 2, 3)

julia> Base.copymutable(tup)
3-element Array{Int64,1}:
3-element Vector{Int64}:
1
2
3
Expand Down Expand Up @@ -1023,20 +1023,20 @@ Return a subset of array `A` as specified by `inds`, where each `ind` may be an
# Examples
```jldoctest
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4

julia> getindex(A, 1)
1

julia> getindex(A, [2, 1])
2-element Array{Int64,1}:
2-element Vector{Int64}:
3
1

julia> getindex(A, 2:4)
3-element Array{Int64,1}:
3-element Vector{Int64}:
3
2
4
Expand Down Expand Up @@ -1130,7 +1130,7 @@ julia> setindex!(A, [10, 20], [1, 2]);
julia> A[[3, 4]] = [30, 40];

julia> A
2×2 Array{Float64,2}:
2×2 Matrix{Float64}:
10.0 30.0
20.0 40.0
```
Expand Down Expand Up @@ -1187,17 +1187,17 @@ during object creation. If the input is not a wrapped object, return the input i
# Examples
```jldoctest
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4

julia> V = view(A, 1:2, :)
2×2 view(::Array{Int64,2}, 1:2, :) with eltype Int64:
2×2 view(::Matrix{Int64}, 1:2, :) with eltype Int64:
1 2
3 4

julia> parent(V)
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4
```
Expand Down Expand Up @@ -1545,16 +1545,16 @@ Concatenate along dimension 1.
# Examples
```jldoctest
julia> a = [1 2 3 4 5]
1×5 Array{Int64,2}:
1×5 Matrix{Int64}:
1 2 3 4 5

julia> b = [6 7 8 9 10; 11 12 13 14 15]
2×5 Array{Int64,2}:
2×5 Matrix{Int64}:
6 7 8 9 10
11 12 13 14 15

julia> vcat(a,b)
3×5 Array{Int64,2}:
3×5 Matrix{Int64}:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
Expand All @@ -1563,7 +1563,7 @@ julia> c = ([1 2 3], [4 5 6])
([1 2 3], [4 5 6])

julia> vcat(c...)
2×3 Array{Int64,2}:
2×3 Matrix{Int64}:
1 2 3
4 5 6
```
Expand All @@ -1577,23 +1577,23 @@ Concatenate along dimension 2.
# Examples
```jldoctest
julia> a = [1; 2; 3; 4; 5]
5-element Array{Int64,1}:
5-element Vector{Int64}:
1
2
3
4
5

julia> b = [6 7; 8 9; 10 11; 12 13; 14 15]
5×2 Array{Int64,2}:
5×2 Matrix{Int64}:
6 7
8 9
10 11
12 13
14 15

julia> hcat(a,b)
5×3 Array{Int64,2}:
5×3 Matrix{Int64}:
1 6 7
2 8 9
3 10 11
Expand All @@ -1604,16 +1604,16 @@ julia> c = ([1; 2; 3], [4; 5; 6])
([1, 2, 3], [4, 5, 6])

julia> hcat(c...)
3×2 Array{Int64,2}:
3×2 Matrix{Int64}:
1 4
2 5
3 6

julia> x = Matrix(undef, 3, 0) # x = [] would have created an Array{Any, 1}, but need an Array{Any, 2}
3×0 Array{Any,2}
3×0 Matrix{Any}

julia> hcat(x, [1; 2; 3])
3×1 Array{Any,2}:
3×1 Matrix{Any}:
1
2
3
Expand Down Expand Up @@ -1682,23 +1682,23 @@ julia> a, b, c, d, e, f = 1, 2, 3, 4, 5, 6
(1, 2, 3, 4, 5, 6)

julia> [a b c; d e f]
2×3 Array{Int64,2}:
2×3 Matrix{Int64}:
1 2 3
4 5 6

julia> hvcat((3,3), a,b,c,d,e,f)
2×3 Array{Int64,2}:
2×3 Matrix{Int64}:
1 2 3
4 5 6

julia> [a b;c d; e f]
3×2 Array{Int64,2}:
3×2 Matrix{Int64}:
1 2
3 4
5 6

julia> hvcat((2,2,2), a,b,c,d,e,f)
3×2 Array{Int64,2}:
3×2 Matrix{Int64}:
1 2
3 4
5 6
Expand Down Expand Up @@ -2161,13 +2161,13 @@ See also: [`mapslices`](@ref)
# Examples
```jldoctest
julia> map(x -> x * 2, [1, 2, 3])
3-element Array{Int64,1}:
3-element Vector{Int64}:
2
4
6

julia> map(+, [1, 2, 3], [10, 20, 30])
3-element Array{Int64,1}:
3-element Vector{Int64}:
11
22
33
Expand Down Expand Up @@ -2220,7 +2220,7 @@ julia> a = zeros(3);
julia> map!(x -> x * 2, a, [1, 2, 3]);

julia> a
3-element Array{Float64,1}:
3-element Vector{Float64}:
2.0
4.0
6.0
Expand Down
40 changes: 20 additions & 20 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ mutable, in which case modifying one will also modify the other.
# Examples
```jldoctest
julia> a = [1 2 3; 4 5 6]
2×3 Array{Int64,2}:
2×3 Matrix{Int64}:
1 2 3
4 5 6

julia> vec(a)
6-element Array{Int64,1}:
6-element Vector{Int64}:
1
4
2
Expand Down Expand Up @@ -109,12 +109,12 @@ Equivalent to `view(A,:,:,...,i,:,:,...)` where `i` is in position `d`.
# Examples
```jldoctest
julia> A = [1 2 3 4; 5 6 7 8]
2×4 Array{Int64,2}:
2×4 Matrix{Int64}:
1 2 3 4
5 6 7 8

julia> selectdim(A, 2, 3)
2-element view(::Array{Int64,2}, :, 3) with eltype Int64:
2-element view(::Matrix{Int64}, :, 3) with eltype Int64:
3
7
```
Expand All @@ -135,12 +135,12 @@ Reverse `A` in dimension `dims`.
# Examples
```jldoctest
julia> b = [1 2; 3 4]
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4

julia> reverse(b, dims=2)
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
2 1
4 3
```
Expand Down Expand Up @@ -191,21 +191,21 @@ first dimension.
# Examples
```jldoctest
julia> b = reshape(Vector(1:16), (4,4))
4×4 Array{Int64,2}:
4×4 Matrix{Int64}:
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16

julia> circshift(b, (0,2))
4×4 Array{Int64,2}:
4×4 Matrix{Int64}:
9 13 1 5
10 14 2 6
11 15 3 7
12 16 4 8

julia> circshift(b, (-1,0))
4×4 Array{Int64,2}:
4×4 Matrix{Int64}:
2 6 10 14
3 7 11 15
4 8 12 16
Expand Down Expand Up @@ -252,7 +252,7 @@ Construct an array by repeating array `A` a given number of times in each dimens
# Examples
```jldoctest
julia> repeat([1, 2, 3], 2)
6-element Array{Int64,1}:
6-element Vector{Int64}:
1
2
3
Expand All @@ -261,7 +261,7 @@ julia> repeat([1, 2, 3], 2)
3

julia> repeat([1, 2, 3], 2, 3)
6×3 Array{Int64,2}:
6×3 Matrix{Int64}:
1 1 1
2 2 2
3 3 3
Expand Down Expand Up @@ -308,21 +308,21 @@ is performed.
# Examples
```jldoctest
julia> repeat(1:2, inner=2)
4-element Array{Int64,1}:
4-element Vector{Int64}:
1
1
2
2

julia> repeat(1:2, outer=2)
4-element Array{Int64,1}:
4-element Vector{Int64}:
1
2
1
2

julia> repeat([1 2; 3 4], inner=(2, 1), outer=(1, 3))
4×6 Array{Int64,2}:
4×6 Matrix{Int64}:
1 2 1 2 1 2
1 2 1 2 1 2
3 4 3 4 3 4
Expand Down Expand Up @@ -428,17 +428,17 @@ See also [`eachcol`](@ref) and [`eachslice`](@ref).

```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4

julia> first(eachrow(a))
2-element view(::Array{Int64,2}, 1, :) with eltype Int64:
2-element view(::Matrix{Int64}, 1, :) with eltype Int64:
1
2

julia> collect(eachrow(a))
2-element Array{SubArray{Int64,1,Array{Int64,2},Tuple{Int64,Base.Slice{Base.OneTo{Int64}}},true},1}:
2-element Vector{SubArray{Int64,1,Matrix{Int64},Tuple{Int64,Base.Slice{Base.OneTo{Int64}}},true}}:
[1, 2]
[3, 4]
```
Expand All @@ -461,17 +461,17 @@ See also [`eachrow`](@ref) and [`eachslice`](@ref).

```jldoctest
julia> a = [1 2; 3 4]
2×2 Array{Int64,2}:
2×2 Matrix{Int64}:
1 2
3 4

julia> first(eachcol(a))
2-element view(::Array{Int64,2}, :, 1) with eltype Int64:
2-element view(::Matrix{Int64}, :, 1) with eltype Int64:
1
3

julia> collect(eachcol(a))
2-element Array{SubArray{Int64,1,Array{Int64,2},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true},1}:
2-element Vector{SubArray{Int64,1,Matrix{Int64},Tuple{Base.Slice{Base.OneTo{Int64}},Int64},true}}:
[1, 3]
[2, 4]
```
Expand Down
4 changes: 2 additions & 2 deletions base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Dict{Char,Int64} with 2 entries:
'b' => 3

julia> collect(keys(D))
2-element Array{Char,1}:
2-element Vector{Char}:
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
```
Expand All @@ -117,7 +117,7 @@ Dict{Char,Int64} with 2 entries:
'b' => 3

julia> collect(values(D))
2-element Array{Int64,1}:
2-element Vector{Int64}:
2
3
```
Expand Down
Loading