From 777393b7a2db3503019d81985592ff71a31624ae Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:51:02 -0400 Subject: [PATCH 1/8] Add StructArrays.jl to docs/Project.toml Manage dependency with `[sources]` attribute. Documentation at . --- docs/Project.toml | 4 ++++ docs/make.jl | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index b741cfe1..f273d9c7 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -2,6 +2,10 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" + +[sources] +StructArrays = {path = ".."} [compat] Documenter = "0.27" diff --git a/docs/make.jl b/docs/make.jl index 8be9672f..2794e3ba 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,5 +1,3 @@ -push!(LOAD_PATH, dirname(@__DIR__)) - using Documenter using StructArrays From 3daa26f132eeaa4b59aa30d241e3e7314066335e Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 15:52:34 -0400 Subject: [PATCH 2/8] Add compat bounds for StaticArrays.jl in docs/Project.toml --- docs/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Project.toml b/docs/Project.toml index f273d9c7..aff92a56 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -10,3 +10,4 @@ StructArrays = {path = ".."} [compat] Documenter = "0.27" PooledArrays = "1" +StaticArrays = "1" From 0781d6d8cc9b86d2ce15b76b4d4702434ecfa052 Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:00:06 -0400 Subject: [PATCH 3/8] Bump compat for Documenter.jl in docs/ environment --- docs/Project.toml | 2 +- docs/make.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index aff92a56..6c93b65e 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -8,6 +8,6 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" StructArrays = {path = ".."} [compat] -Documenter = "0.27" +Documenter = "1" PooledArrays = "1" StaticArrays = "1" diff --git a/docs/make.jl b/docs/make.jl index 2794e3ba..0372d8aa 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -11,7 +11,8 @@ makedocs( "Some counterintuitive behaviors"=>"counterintuitive.md", "Advanced techniques"=>"advanced.md", "Index"=>"reference.md", - ] + ], + warnonly = [:missing_docs], ) # Documenter can also automatically deploy documentation to gh-pages. From 3736b5e2ece68722c2bd3f9ed06ea920e9f27829 Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:09:52 -0400 Subject: [PATCH 4/8] Update syntax highlight tags for REPL code examples --- docs/src/advanced.md | 4 ++-- docs/src/examples.md | 10 +++++----- docs/src/index.md | 16 ++++++++-------- src/interface.jl | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/src/advanced.md b/docs/src/advanced.md index b529fb99..6aa5dd91 100644 --- a/docs/src/advanced.md +++ b/docs/src/advanced.md @@ -66,7 +66,7 @@ StructArrays provides a function `StructArrays.append!!(dest, src)` (unexported) `StructArrays.append!!` works like `append!(dest, src)` if `dest` can contain all element types in `src` iterator; i.e., it _mutates_ `dest` in-place: -```julia +```julia-repl julia> dest = StructVector((a=[1], b=[2])) 1-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}: (a = 1, b = 2) @@ -82,7 +82,7 @@ true Unlike `append!`, `append!!` can also _widen_ element type of `dest` array: -```julia +```julia-repl julia> StructArrays.append!!(dest, [(a = missing, b = 6)]) 3-element StructArray(::Array{Union{Missing, Int64},1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}: NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((1, 2)) diff --git a/docs/src/examples.md b/docs/src/examples.md index 0a4e4388..116d7961 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -1,6 +1,6 @@ ## Example usage to store complex numbers -```julia +```julia-repl julia> using StructArrays, Random julia> Random.seed!(4); @@ -24,7 +24,7 @@ julia> StructArrays.components(s) # obtain all field arrays as a named tuple Note that the same approach can be used directly from an `Array` of complex numbers: -```julia +```julia-repl julia> StructArray([1+im, 3-2im]) 2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype Complex{Int64}: 1 + 1im @@ -33,7 +33,7 @@ julia> StructArray([1+im, 3-2im]) ## Example usage to store a data table -```julia +```julia-repl julia> t = StructArray((a = [1, 2], b = ["x", "y"])) 2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: (a = 1, b = "x") @@ -56,7 +56,7 @@ julia> push!(t, (a = 3, b = "z")) ## Example usage with StaticArray elements -```julia +```julia-repl julia> using StructArrays, StaticArrays julia> x = StructArray([SVector{2}(1,2) for i = 1:5]) @@ -84,4 +84,4 @@ julia> B = StructArray([SArray{Tuple{2,2,2}}(reshape(1:8,2,2,2)) for i = 1:5]); [:, :, 2] = 5 7 6 8 -``` \ No newline at end of file +``` diff --git a/docs/src/index.md b/docs/src/index.md index 86059778..653672e6 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -46,7 +46,7 @@ StructArray(log(j+2.0*im) for j in 1:10) 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: -```julia +```julia-repl julia> s = StructArray{ComplexF64}(undef, 2, 2) 2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}: 6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im @@ -88,7 +88,7 @@ julia> soa.re `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: -```julia +```julia-repl julia> using StructArrays, CuArrays julia> a = CuArray(rand(Float32, 10)); @@ -126,7 +126,7 @@ julia> StructArray(c) 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`: -```julia +```julia-repl julia> s = StructArray([1.0+im, 2.0-im]) 2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}: 1.0 + 1.0im @@ -142,7 +142,7 @@ julia> replace_storage(CuArray, s) `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. -```julia +```julia-repl julia> t = StructArray((a = [1, 2], b = ["x", "y"])); julia> LazyRow(t, 2).a @@ -159,7 +159,7 @@ julia> t To iterate in a lazy way one can simply iterate `LazyRows`: -```julia +```julia-repl julia> map(t -> t.b ^ t.a, LazyRows(t)) 2-element Array{String,1}: "x" @@ -168,10 +168,10 @@ julia> map(t -> t.b ^ t.a, LazyRows(t)) ## Applying a function on each field array -```julia +```julia-repl julia> struct Foo - a::Int - b::String + a::Int + b::String end julia> s = StructArray([Foo(11, "a"), Foo(22, "b"), Foo(33, "c"), Foo(44, "d"), Foo(55, "e")]); diff --git a/src/interface.jl b/src/interface.jl index 2f07eee2..64c53f95 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -19,7 +19,7 @@ this will have fields with the same names and types as `T`. This can be overloaded for custom types if required, in which case [`StructArrays.component`](@ref) and [`StructArrays.createinstance`](@ref) should also be defined. - + ```julia-repl julia> StructArrays.staticschema(Complex{Float64}) NamedTuple{(:re, :im),Tuple{Float64,Float64}} From 5bb05cdd527cc18addd85e9f4acdff2257529827 Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:10:15 -0400 Subject: [PATCH 5/8] Use `@meta` block for doctest setup in counterintuitive.md --- docs/src/counterintuitive.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/counterintuitive.md b/docs/src/counterintuitive.md index a400e229..0d510dde 100644 --- a/docs/src/counterintuitive.md +++ b/docs/src/counterintuitive.md @@ -1,3 +1,6 @@ +```@meta +DocTestSetup = :(using StructArrays) +``` # Some counterintuitive behaviors When created from parent arrays representing each field of the final `struct`, StructArrays creates a "view" which @@ -13,7 +16,7 @@ These issues are elucidated below. For this demonstration, throughout we'll use this mutable struct: -```jldoctest counter1; setup=:(using StructArrays) +```jldoctest counter1 julia> mutable struct Foo{T} a::T b::T @@ -181,7 +184,7 @@ None of the changes to `soa` "propagated" to `aos`. This is because a StructArra ## Broadcasted assignment for array entries Broadcasted in-place assignment can also behave counterintuitively for StructArrays. -```jldoctest; setup=:(using StructArrays) +```jldoctest julia> using StaticArrays # for FieldVector julia> mutable struct Bar{T} <: FieldVector{2,T} From a089050f4c5c88d99b698d9b9f5d10485f47bac0 Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:10:26 -0400 Subject: [PATCH 6/8] Fix markdown ordered list syntax --- src/structarray.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structarray.jl b/src/structarray.jl index 562348de..a8de5121 100644 --- a/src/structarray.jl +++ b/src/structarray.jl @@ -532,9 +532,9 @@ BroadcastStyle(::Type{SA}) where {SA<:StructArray} = StructArrayStyle{typeof(cst always_struct_broadcast(style::BroadcastStyle) Check if `style` supports struct-broadcast natively, which means: -1) `Base.copy` is not overloaded. -2) `Base.similar` is defined. -3) `Base.copyto!` supports `StructArray`s as broadcasted arguments. +1. `Base.copy` is not overloaded. +2. `Base.similar` is defined. +3. `Base.copyto!` supports `StructArray`s as broadcasted arguments. If any of the above conditions are not met, then this function should not be overloaded. From 2c9084425967426c92136a68abfbaed5e9e8675e Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:12:59 -0400 Subject: [PATCH 7/8] Add syntax highlight tag to example code block --- src/structarray.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structarray.jl b/src/structarray.jl index a8de5121..607bc5dc 100644 --- a/src/structarray.jl +++ b/src/structarray.jl @@ -136,7 +136,7 @@ julia> StructArray{Complex{Float64}}(X; dims=2) ``` By default, fields will be unwrapped until they match the element type of the array: -``` +```julia-repl julia> StructArray{Tuple{Float64,Complex{Float64}}}(rand(3,2); dims=1) 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}}: (0.004767505234193781, 0.27949621887414566 + 0.9039320635041561im) From d352061262af328e4efb71654b195e13a629f130 Mon Sep 17 00:00:00 2001 From: Abhro <5664668+abhro@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:21:57 -0400 Subject: [PATCH 8/8] Update type repr in code examples --- docs/src/advanced.md | 6 +++--- docs/src/examples.md | 12 ++++++------ docs/src/index.md | 12 ++++++------ src/lazy.jl | 4 ++-- src/structarray.jl | 28 ++++++++++++++-------------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/src/advanced.md b/docs/src/advanced.md index 6aa5dd91..3ed76d10 100644 --- a/docs/src/advanced.md +++ b/docs/src/advanced.md @@ -68,11 +68,11 @@ StructArrays provides a function `StructArrays.append!!(dest, src)` (unexported) ```julia-repl julia> dest = StructVector((a=[1], b=[2])) -1-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}: +1-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}: (a = 1, b = 2) julia> StructArrays.append!!(dest, [(a = 3, b = 4)]) -2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}: +2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}: (a = 1, b = 2) (a = 3, b = 4) @@ -84,7 +84,7 @@ Unlike `append!`, `append!!` can also _widen_ element type of `dest` array: ```julia-repl julia> StructArrays.append!!(dest, [(a = missing, b = 6)]) -3-element StructArray(::Array{Union{Missing, Int64},1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}: +3-element StructArray(::Vector{Union{Missing, Int64}}, ::Vector{Int64}) with eltype NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}: NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((1, 2)) NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((3, 4)) NamedTuple{(:a, :b),Tuple{Union{Missing, Int64},Int64}}((missing, 6)) diff --git a/docs/src/examples.md b/docs/src/examples.md index 116d7961..d45ca515 100644 --- a/docs/src/examples.md +++ b/docs/src/examples.md @@ -6,7 +6,7 @@ julia> using StructArrays, Random julia> Random.seed!(4); julia> s = StructArray{ComplexF64}((rand(2,2), rand(2,2))) -2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}: +2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}: 0.680079+0.625239im 0.92407+0.267358im 0.874437+0.737254im 0.929336+0.804478im @@ -14,7 +14,7 @@ julia> s[1, 1] 0.680079235935741 + 0.6252391193298537im julia> s.re -2×2 Array{Float64,2}: +2×2 Matrix{Float64}: 0.680079 0.92407 0.874437 0.929336 @@ -26,7 +26,7 @@ Note that the same approach can be used directly from an `Array` of complex numb ```julia-repl julia> StructArray([1+im, 3-2im]) -2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype Complex{Int64}: +2-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype Complex{Int64}: 1 + 1im 3 - 2im ``` @@ -35,7 +35,7 @@ julia> StructArray([1+im, 3-2im]) ```julia-repl julia> t = StructArray((a = [1, 2], b = ["x", "y"])) -2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: +2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: (a = 1, b = "x") (a = 2, b = "y") @@ -43,12 +43,12 @@ julia> t[1] (a = 1, b = "x") julia> t.a -2-element Array{Int64,1}: +2-element Vector{Int64}: 1 2 julia> push!(t, (a = 3, b = "z")) -3-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: +3-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: (a = 1, b = "x") (a = 2, b = "y") (a = 3, b = "z") diff --git a/docs/src/index.md b/docs/src/index.md index 653672e6..26d5f569 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -48,12 +48,12 @@ Another option is to create an uninitialized `StructArray` and then fill it with ```julia-repl julia> s = StructArray{ComplexF64}(undef, 2, 2) -2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}: +2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}: 6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im 6.91646e-310+6.91646e-310im julia> rand!(s) -2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}: +2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}: 0.680079+0.874437im 0.625239+0.737254im 0.92407+0.929336im 0.267358+0.804478im ``` @@ -111,7 +111,7 @@ julia> StructArray{ComplexF32}((a, b)) julia> c = CuArray(rand(ComplexF32, 10)); julia> StructArray(c) -10-element StructArray(::Array{Float32,1}, ::Array{Float32,1}) with eltype Complex{Float32}: +10-element StructArray(::Vector{Float32}, ::Vector{Float32}) with eltype Complex{Float32}: 0.7176411f0 + 0.864058f0im 0.252609f0 + 0.14824867f0im 0.26842773f0 + 0.9084332f0im @@ -128,7 +128,7 @@ If you already have your data in a `StructArray` with field arrays of a given fo ```julia-repl julia> s = StructArray([1.0+im, 2.0-im]) -2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}: +2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}: 1.0 + 1.0im 2.0 - 1.0im @@ -152,7 +152,7 @@ julia> LazyRow(t, 2).a = 123 123 julia> t -2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: +2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: (a = 1, b = "x") (a = 123, b = "y") ``` @@ -161,7 +161,7 @@ To iterate in a lazy way one can simply iterate `LazyRows`: ```julia-repl julia> map(t -> t.b ^ t.a, LazyRows(t)) -2-element Array{String,1}: +2-element Vector{String}: "x" "yy" ``` diff --git a/src/lazy.jl b/src/lazy.jl index 863c3e1f..aacb599a 100644 --- a/src/lazy.jl +++ b/src/lazy.jl @@ -20,7 +20,7 @@ julia> LazyRow(t, 2).a = 123 123 julia> t -2-element StructArray(::Array{Int64,1}, ::Array{String,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: +2-element StructArray(::Vector{Int64}, ::Vector{String}) with eltype NamedTuple{(:a, :b),Tuple{Int64,String}}: (a = 1, b = "x") (a = 123, b = "y") ``` @@ -68,7 +68,7 @@ An iterator of [`LazyRow`](@ref)s of `s`. ```julia-repl julia> map(t -> t.b ^ t.a, LazyRows(t)) -2-element Array{String,1}: +2-element Vector{String}: "x" "yy" ``` diff --git a/src/structarray.jl b/src/structarray.jl index 607bc5dc..687af610 100644 --- a/src/structarray.jl +++ b/src/structarray.jl @@ -55,12 +55,12 @@ specified field arrays. ```julia-repl julia> StructArray{ComplexF64}(([1.0, 2.0], [3.0, 4.0])) -2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}: +2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}: 1.0 + 3.0im 2.0 + 4.0im julia> StructArray{ComplexF64}(re=[1.0, 2.0], im=[3.0, 4.0]) -2-element StructArray(::Array{Float64,1}, ::Array{Float64,1}) with eltype Complex{Float64}: +2-element StructArray(::Vector{Float64}, ::Vector{Float64}) with eltype Complex{Float64}: 1.0 + 3.0im 2.0 + 4.0im ``` @@ -68,7 +68,7 @@ julia> StructArray{ComplexF64}(re=[1.0, 2.0], im=[3.0, 4.0]) Any `AbstractArray` can be used as a field array ```julia-repl julia> StructArray{Complex{Int64}}(([1, 2], 3:4)) -2-element StructArray(::Array{Int64,1}, ::UnitRange{Int64}) with eltype Complex{Int64}: +2-element StructArray(::Vector{Int64}, ::UnitRange{Int64}) with eltype Complex{Int64}: 1 + 3im 2 + 4im ``` @@ -76,12 +76,12 @@ julia> StructArray{Complex{Int64}}(([1, 2], 3:4)) If no element type `T` is provided, a `Tuple` or `NamedTuple` is used: ```julia-repl julia> StructArray((zeros(2,2), ones(2,2))) -2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Tuple{Float64,Float64}: +2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Tuple{Float64,Float64}: (0.0, 1.0) (0.0, 1.0) (0.0, 1.0) (0.0, 1.0) julia> StructArray(a=zeros(2,2), b=ones(2,2)) -2×2 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype NamedTuple{(:a, :b),Tuple{Float64,Float64}}: +2×2 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype NamedTuple{(:a, :b),Tuple{Float64,Float64}}: (a = 0.0, b = 1.0) (a = 0.0, b = 1.0) (a = 0.0, b = 1.0) (a = 0.0, b = 1.0) ``` @@ -120,17 +120,17 @@ recursively convert fields of type `FT` to `StructArray`s. ```julia-repl julia> X = [1.0 2.0; 3.0 4.0] -2×2 Array{Float64,2}: +2×2 Matrix{Float64}: 1.0 2.0 3.0 4.0 julia> StructArray{Complex{Float64}}(X; dims=1) -2-element StructArray(view(::Array{Float64,2}, 1, :), view(::Array{Float64,2}, 2, :)) with eltype Complex{Float64}: +2-element StructArray(view(::Matrix{Float64}, 1, :), view(::Matrix{Float64}, 2, :)) with eltype Complex{Float64}: 1.0 + 3.0im 2.0 + 4.0im julia> StructArray{Complex{Float64}}(X; dims=2) -2-element StructArray(view(::Array{Float64,2}, :, 1), view(::Array{Float64,2}, :, 2)) with eltype Complex{Float64}: +2-element StructArray(view(::Matrix{Float64}, :, 1), view(::Matrix{Float64}, :, 2)) with eltype Complex{Float64}: 1.0 + 2.0im 3.0 + 4.0im ``` @@ -138,7 +138,7 @@ julia> StructArray{Complex{Float64}}(X; dims=2) By default, fields will be unwrapped until they match the element type of the array: ```julia-repl julia> StructArray{Tuple{Float64,Complex{Float64}}}(rand(3,2); dims=1) -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}}: +2-element StructArray(view(::Matrix{Float64}, 1, :), StructArray(view(::Matrix{Float64}, 2, :), view(::Matrix{Float64}, 3, :))) with eltype Tuple{Float64,Complex{Float64}}: (0.004767505234193781, 0.27949621887414566 + 0.9039320635041561im) (0.41853472213051335, 0.5760165160827859 + 0.9782723869433818im) ``` @@ -195,7 +195,7 @@ recursively convert arrays of element type `T` to `StructArray`s. ```julia-repl julia> StructArray{ComplexF64}(undef, (2,3)) -2×3 StructArray(::Array{Float64,2}, ::Array{Float64,2}) with eltype Complex{Float64}: +2×3 StructArray(::Matrix{Float64}, ::Matrix{Float64}) with eltype Complex{Float64}: 2.3166e-314+2.38405e-314im 2.39849e-314+2.38405e-314im 2.41529e-314+2.38405e-314im 2.31596e-314+2.41529e-314im 2.31596e-314+2.41529e-314im 2.31596e-314+NaN*im ``` @@ -222,12 +222,12 @@ recursively convert arrays of element type `T` to `StructArray`s. ```julia-repl julia> A = rand(ComplexF32, 2,2) -2×2 Array{Complex{Float32},2}: +2×2 Matrix{Complex{Float32}}: 0.694399+0.94999im 0.422804+0.891131im 0.101001+0.33644im 0.632468+0.811319im julia> StructArray(A) -2×2 StructArray(::Array{Float32,2}, ::Array{Float32,2}) with eltype Complex{Float32}: +2×2 StructArray(::Matrix{Float32}, ::Matrix{Float32}) with eltype Complex{Float32}: 0.694399+0.94999im 0.422804+0.891131im 0.101001+0.33644im 0.632468+0.811319im ``` @@ -236,7 +236,7 @@ julia> StructArray(A) ```julia-repl julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4) -3×3 StructArray(::Array{Int64,2}, ::Array{Complex{Int64},2}) with eltype Tuple{Int64,Complex{Int64}}: +3×3 StructArray(::Matrix{Int64}, ::Matrix{Complex{Int64}}) with eltype Tuple{Int64,Complex{Int64}}: (1, 1+2im) (1, 1+3im) (1, 1+4im) (1, 2+2im) (1, 2+3im) (1, 2+4im) (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) ```julia-repl julia> StructArray((1, Complex(i, j)) for i = 1:3, j = 2:4; unwrap = T -> !(T<:Real)) -3×3 StructArray(::Array{Int64,2}, StructArray(::Array{Int64,2}, ::Array{Int64,2})) with eltype Tuple{Int64,Complex{Int64}}: +3×3 StructArray(::Matrix{Int64}, StructArray(::Matrix{Int64}, ::Matrix{Int64})) with eltype Tuple{Int64,Complex{Int64}}: (1, 1+2im) (1, 1+3im) (1, 1+4im) (1, 2+2im) (1, 2+3im) (1, 2+4im) (1, 3+2im) (1, 3+3im) (1, 3+4im)