Skip to content

Commit d352061

Browse files
committed
Update type repr in code examples
1 parent 2c90844 commit d352061

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

docs/src/advanced.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ StructArrays provides a function `StructArrays.append!!(dest, src)` (unexported)
6868

6969
```julia-repl
7070
julia> dest = StructVector((a=[1], b=[2]))
71-
1-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
71+
1-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
7272
(a = 1, b = 2)
7373
7474
julia> StructArrays.append!!(dest, [(a = 3, b = 4)])
75-
2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
75+
2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
7676
(a = 1, b = 2)
7777
(a = 3, b = 4)
7878
@@ -84,7 +84,7 @@ Unlike `append!`, `append!!` can also _widen_ element type of `dest` array:
8484

8585
```julia-repl
8686
julia> StructArrays.append!!(dest, [(a = missing, b = 6)])
87-
3-element StructArray(::Array{Union{Missing, Int64},1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}:
87+
3-element StructArray(::Vector{Union{Missing, Int64}}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}:
8888
NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((1, 2))
8989
NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((3, 4))
9090
NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((missing, 6))

docs/src/examples.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ julia> using StructArrays, Random
66
julia> Random.seed!(4);
77
88
julia> s = StructArray{ComplexF64}((rand(2,2), rand(2,2)))
9-
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}:
9+
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}:
1010
0.680079+0.625239im 0.92407+0.267358im
1111
0.874437+0.737254im 0.929336+0.804478im
1212
1313
julia> s[1, 1]
1414
0.680079235935741 + 0.6252391193298537im
1515
1616
julia> s.re
17-
2×2 Array{Float64,2}:
17+
2×2 Matrix{Float64}:
1818
0.680079 0.92407
1919
0.874437 0.929336
2020
@@ -26,7 +26,7 @@ Note that the same approach can be used directly from an `Array` of complex numb
2626

2727
```julia-repl
2828
julia> StructArray([1+im, 3-2im])
29-
2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype Complex{Int64}:
29+
2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}:
3030
1 + 1im
3131
3 - 2im
3232
```
@@ -35,20 +35,20 @@ julia> StructArray([1+im, 3-2im])
3535

3636
```julia-repl
3737
julia> t = StructArray((a = [1, 2], b = ["x", "y"]))
38-
2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
38+
2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
3939
(a = 1, b = "x")
4040
(a = 2, b = "y")
4141
4242
julia> t[1]
4343
(a = 1, b = "x")
4444
4545
julia> t.a
46-
2-element Array{Int64,1}:
46+
2-element Vector{Int64}:
4747
1
4848
2
4949
5050
julia> push!(t, (a = 3, b = "z"))
51-
3-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
51+
3-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
5252
(a = 1, b = "x")
5353
(a = 2, b = "y")
5454
(a = 3, b = "z")

docs/src/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ Another option is to create an uninitialized `StructArray` and then fill it with
4848

4949
```julia-repl
5050
julia> s = StructArray{ComplexF64}(undef, 2, 2)
51-
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}:
51+
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}:
5252
6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im
5353
6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im
5454
5555
julia> rand!(s)
56-
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}:
56+
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}:
5757
0.680079+0.874437im 0.625239+0.737254im
5858
0.92407+0.929336im 0.267358+0.804478im
5959
```
@@ -111,7 +111,7 @@ julia> StructArray{ComplexF32}((a, b))
111111
julia> c = CuArray(rand(ComplexF32, 10));
112112
113113
julia> StructArray(c)
114-
10-element StructArray(::Array{Float32,1}, ::Array{Float32,1}) with eltype Complex{Float32}:
114+
10-element StructArray(::Vector{Float32}, ::Vector{Float32}) with eltype Complex{Float32}:
115115
0.7176411f0 + 0.864058f0im
116116
0.252609f0 + 0.14824867f0im
117117
0.26842773f0 + 0.9084332f0im
@@ -128,7 +128,7 @@ If you already have your data in a `StructArray` with field arrays of a given fo
128128

129129
```julia-repl
130130
julia> s = StructArray([1.0+im, 2.0-im])
131-
2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}:
131+
2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}:
132132
1.0 + 1.0im
133133
2.0 - 1.0im
134134
@@ -152,7 +152,7 @@ julia> LazyRow(t, 2).a = 123
152152
123
153153
154154
julia> t
155-
2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
155+
2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
156156
(a = 1, b = "x")
157157
(a = 123, b = "y")
158158
```
@@ -161,7 +161,7 @@ To iterate in a lazy way one can simply iterate `LazyRows`:
161161

162162
```julia-repl
163163
julia> map(t -> t.b ^ t.a, LazyRows(t))
164-
2-element Array{String,1}:
164+
2-element Vector{String}:
165165
"x"
166166
"yy"
167167
```

src/lazy.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ julia> LazyRow(t, 2).a = 123
2020
123
2121
2222
julia> t
23-
2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
23+
2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}:
2424
(a = 1, b = "x")
2525
(a = 123, b = "y")
2626
```
@@ -68,7 +68,7 @@ An iterator of [`LazyRow`](@ref)s of `s`.
6868
6969
```julia-repl
7070
julia> map(t -> t.b ^ t.a, LazyRows(t))
71-
2-element Array{String,1}:
71+
2-element Vector{String}:
7272
"x"
7373
"yy"
7474
```

src/structarray.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,33 @@ specified field arrays.
5555
5656
```julia-repl
5757
julia> StructArray{ComplexF64}(([1.0, 2.0], [3.0, 4.0]))
58-
2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}:
58+
2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}:
5959
1.0 + 3.0im
6060
2.0 + 4.0im
6161
6262
julia> StructArray{ComplexF64}(re=[1.0, 2.0], im=[3.0, 4.0])
63-
2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}:
63+
2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}:
6464
1.0 + 3.0im
6565
2.0 + 4.0im
6666
```
6767
6868
Any `AbstractArray` can be used as a field array
6969
```julia-repl
7070
julia> StructArray{Complex{Int64}}(([1, 2], 3:4))
71-
2-element StructArray(::Array{Int64,1}, ::UnitRange{Int64}) with eltype Complex{Int64}:
71+
2-element StructArray(::Vector{Int64}, ::UnitRange{Int64}) with eltype Complex{Int64}:
7272
1 + 3im
7373
2 + 4im
7474
```
7575
7676
If no element type `T` is provided, a `Tuple` or `NamedTuple` is used:
7777
```julia-repl
7878
julia> StructArray((zeros(2,2), ones(2,2)))
79-
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Tuple{Float64,Float64}:
79+
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Tuple{Float64,Float64}:
8080
(0.0, 1.0) (0.0, 1.0)
8181
(0.0, 1.0) (0.0, 1.0)
8282
8383
julia> StructArray(a=zeros(2,2), b=ones(2,2))
84-
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype NamedTuple{(:a, :b),Tuple{Float64,Float64}}:
84+
2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype NamedTuple{(:a, :b),Tuple{Float64,Float64}}:
8585
(a = 0.0, b = 1.0) (a = 0.0, b = 1.0)
8686
(a = 0.0, b = 1.0) (a = 0.0, b = 1.0)
8787
```
@@ -120,25 +120,25 @@ recursively convert fields of type `FT` to `StructArray`s.
120120
121121
```julia-repl
122122
julia> X = [1.0 2.0; 3.0 4.0]
123-
2×2 Array{Float64,2}:
123+
2×2 Matrix{Float64}:
124124
1.0 2.0
125125
3.0 4.0
126126
127127
julia> StructArray{Complex{Float64}}(X; dims=1)
128-
2-element StructArray(view(::Array{Float64,2}, 1, :), view(::Array{Float64,2}, 2, :)) with eltype Complex{Float64}:
128+
2-element StructArray(view(::Matrix{Float64}, 1, :), view(::Matrix{Float64}, 2, :)) with eltype Complex{Float64}:
129129
1.0 + 3.0im
130130
2.0 + 4.0im
131131
132132
julia> StructArray{Complex{Float64}}(X; dims=2)
133-
2-element StructArray(view(::Array{Float64,2}, :, 1), view(::Array{Float64,2}, :, 2)) with eltype Complex{Float64}:
133+
2-element StructArray(view(::Matrix{Float64}, :, 1), view(::Matrix{Float64}, :, 2)) with eltype Complex{Float64}:
134134
1.0 + 2.0im
135135
3.0 + 4.0im
136136
```
137137
138138
By default, fields will be unwrapped until they match the element type of the array:
139139
```julia-repl
140140
julia> StructArray{Tuple{Float64,Complex{Float64}}}(rand(3,2); dims=1)
141-
2-element StructArray(view(::Array{Float64,2}, 1, :), StructArray(view(::Array{Float64,2}, 2, :), view(::Array{Float64,2}, 3, :))) with eltype Tuple{Float64,Complex{Float64}}:
141+
2-element StructArray(view(::Matrix{Float64}, 1, :), StructArray(view(::Matrix{Float64}, 2, :), view(::Matrix{Float64}, 3, :))) with eltype Tuple{Float64,Complex{Float64}}:
142142
(0.004767505234193781, 0.27949621887414566 + 0.9039320635041561im)
143143
(0.41853472213051335, 0.5760165160827859 + 0.9782723869433818im)
144144
```
@@ -195,7 +195,7 @@ recursively convert arrays of element type `T` to `StructArray`s.
195195
196196
```julia-repl
197197
julia> StructArray{ComplexF64}(undef, (2,3))
198-
2×3 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}:
198+
2×3 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}:
199199
2.3166e-314+2.38405e-314im 2.39849e-314+2.38405e-314im 2.41529e-314+2.38405e-314im
200200
2.31596e-314+2.41529e-314im 2.31596e-314+2.41529e-314im 2.31596e-314+NaN*im
201201
```
@@ -222,12 +222,12 @@ recursively convert arrays of element type `T` to `StructArray`s.
222222
223223
```julia-repl
224224
julia> A = rand(ComplexF32, 2,2)
225-
2×2 Array{Complex{Float32},2}:
225+
2×2 Matrix{Complex{Float32}}:
226226
0.694399+0.94999im 0.422804+0.891131im
227227
0.101001+0.33644im 0.632468+0.811319im
228228
229229
julia> StructArray(A)
230-
2×2 StructArray(::Array{Float32,2}, ::Array{Float32,2}) with eltype Complex{Float32}:
230+
2×2 StructArray(::Matrix{Float32}, ::Matrix{Float32}) with eltype Complex{Float32}:
231231
0.694399+0.94999im 0.422804+0.891131im
232232
0.101001+0.33644im 0.632468+0.811319im
233233
```
@@ -236,7 +236,7 @@ julia> StructArray(A)
236236
237237
```julia-repl
238238
julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4)
239-
3×3 StructArray(::Array{Int64,2}, ::Array{Complex{Int64},2}) with eltype Tuple{Int64,Complex{Int64}}:
239+
3×3 StructArray(::Matrix{Int64}, ::Matrix{Complex{Int64}}) with eltype Tuple{Int64,Complex{Int64}}:
240240
(1, 1+2im) (1, 1+3im) (1, 1+4im)
241241
(1, 2+2im) (1, 2+3im) (1, 2+4im)
242242
(1, 3+2im) (1, 3+3im) (1, 3+4im)
@@ -246,7 +246,7 @@ julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4)
246246
247247
```julia-repl
248248
julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4; unwrap = T -> !(T<:Real))
249-
3×3 StructArray(::Array{Int64,2}, StructArray(::Array{Int64,2}, ::Array{Int64,2})) with eltype Tuple{Int64,Complex{Int64}}:
249+
3×3 StructArray(::Matrix{Int64}, StructArray(::Matrix{Int64}, ::Matrix{Int64})) with eltype Tuple{Int64,Complex{Int64}}:
250250
(1, 1+2im) (1, 1+3im) (1, 1+4im)
251251
(1, 2+2im) (1, 2+3im) (1, 2+4im)
252252
(1, 3+2im) (1, 3+3im) (1, 3+4im)

0 commit comments

Comments
 (0)