You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/index.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ StructArray(log(j+2.0*im) for j in 1:10)
46
46
47
47
Another option is to create an uninitialized `StructArray` and then fill it with data. Just like in normal arrays, this is done with the `undef` syntax:
48
48
49
-
```julia
49
+
```julia-repl
50
50
julia> s = StructArray{ComplexF64}(undef, 2, 2)
51
51
2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}:
`StructArray`s supports using custom array types. It is always possible to pass field arrays of a custom type. The "custom array of `struct`s to `struct` of custom arrays" transformation will use the `similar` method of the custom array type. This can be useful when working on the GPU for example:
90
90
91
-
```julia
91
+
```julia-repl
92
92
julia> using StructArrays, CuArrays
93
93
94
94
julia> a = CuArray(rand(Float32, 10));
@@ -126,7 +126,7 @@ julia> StructArray(c)
126
126
127
127
If you already have your data in a `StructArray` with field arrays of a given format (say plain `Array`) you can change them with `replace_storage`:
128
128
129
-
```julia
129
+
```julia-repl
130
130
julia> s = StructArray([1.0+im, 2.0-im])
131
131
2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}:
`StructArray`s also provides a `LazyRow` wrapper for lazy row iteration. `LazyRow(t, i)` does not materialize the i-th row but returns a lazy wrapper around it on which `getproperty` does the correct thing. This is useful when the row has many fields only some of which are necessary. It also allows changing columns in place.
144
144
145
-
```julia
145
+
```julia-repl
146
146
julia> t = StructArray((a = [1, 2], b = ["x", "y"]));
147
147
148
148
julia> LazyRow(t, 2).a
@@ -159,7 +159,7 @@ julia> t
159
159
160
160
To iterate in a lazy way one can simply iterate `LazyRows`:
0 commit comments