From 46f3d115fe192a28dcd726f04b1aeb784a306ab4 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Tue, 18 Jun 2024 16:58:15 +0200 Subject: [PATCH 1/8] added new methods to similar_arr_type to deal with SubArray ReshapedArray and ReinterpretArray --- Manifest.toml | 73 ++++++++++++++++++++++++++++++++++++++++++++++ src/type_tools.jl | 24 +++++++++++---- test/type_tools.jl | 12 ++++---- 3 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 Manifest.toml diff --git a/Manifest.toml b/Manifest.toml new file mode 100644 index 0000000..701204c --- /dev/null +++ b/Manifest.toml @@ -0,0 +1,73 @@ +# This file is machine-generated - editing it directly is not advised + +julia_version = "1.10.4" +manifest_format = "2.0" +project_hash = "d72cac80c925125123481871f3a9328105af9ce9" + +[[deps.Artifacts]] +uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" + +[[deps.CompilerSupportLibraries_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" +version = "1.1.1+0" + +[[deps.Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[deps.LinearAlgebra]] +deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[deps.OffsetArrays]] +git-tree-sha1 = "e64b4f5ea6b7389f6f046d13d4896a8f9c1ba71e" +uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" +version = "1.14.0" + + [deps.OffsetArrays.extensions] + OffsetArraysAdaptExt = "Adapt" + + [deps.OffsetArrays.weakdeps] + Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" + +[[deps.OpenBLAS_jll]] +deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] +uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +version = "0.3.23+4" + +[[deps.PaddedViews]] +deps = ["OffsetArrays"] +git-tree-sha1 = "0fac6313486baae819364c52b4f483450a9d793f" +uuid = "5432bcbf-9aad-5242-b902-cca2824c8663" +version = "0.5.12" + +[[deps.Random]] +deps = ["SHA"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[deps.SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +version = "0.7.0" + +[[deps.Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[deps.SparseArrays]] +deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" +version = "1.10.0" + +[[deps.Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +version = "1.10.0" + +[[deps.SuiteSparse_jll]] +deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] +uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" +version = "7.2.1+1" + +[[deps.libblastrampoline_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" +version = "5.8.0+1" diff --git a/src/type_tools.jl b/src/type_tools.jl index 1408d12..ad2f4cb 100644 --- a/src/type_tools.jl +++ b/src/type_tools.jl @@ -59,13 +59,13 @@ end """ - similar_arr_type(::Type{TA}) where {TA<:AbstractArray} + similar_arr_type(::Type{TA}; dims=N, dtype=T) where {TA<:AbstractArray} returns a similar array type but using as TA, but eltype and ndims can be changed. # Arguments + `TA`: The array type to convert to an eltype of `complex(eltype(TA))` -+ `dims`: The number of dimensions of the returned array type ++ `dims`: The number of dimensions of the returned array type. Please specify this as a ::Val type to be type-stable. Default is Val(1). + `dtype`: The `eltype()` of the returned array type. # Example @@ -81,10 +81,24 @@ julia> similar_arr_type(Array{ComplexF64,3}, dims=2, dtype=Int) Matrix{Int64} (alias for Array{Int64, 2}) ``` """ -function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T,N, TA<:AbstractArray{T,N}} +function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, TA<:AbstractArray{T,N}} typeof(similar(TA(undef, ntuple(x->0, N)), dtype, ntuple(x->0, dims))) end - -function similar_arr_type(::Type{TA}; dims=1, dtype=eltype(TA)) where {TA<:AbstractArray} + +function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, P, I, L, TA<:SubArray{T,N,P,I,L}} + similar_arr_type(P, dims=dims, dtype=dtype) +end + +function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, P, MI, TA<:Base.ReshapedArray{T,N,P,MI}} + similar_arr_type(P, dims=dims, dtype=dtype) +end + +# note that T refers to the new type (if not explicitely specified) and therefore replaces the eltype of the array as defined by P +function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, O, P, B, TA<:Base.ReinterpretArray{T,N,O,P,B}} + similar_arr_type(P, dims=dims, dtype=dtype) +end + +function similar_arr_type(::Type{TA}; dims=Val(1), dtype=eltype(TA)) where {TA<:AbstractArray} typeof(similar(TA(undef), dtype, ntuple(x->0, dims))) end + diff --git a/test/type_tools.jl b/test/type_tools.jl index 0c2e514..28dfe5d 100644 --- a/test/type_tools.jl +++ b/test/type_tools.jl @@ -2,10 +2,12 @@ sz = (11,12) @test real_arr_type(Array{Float32,2}) == Matrix{Float32} @test complex_arr_type(Array{Float32,1}, dims=2) == Matrix{ComplexF32} - @test real_arr_type(Array{Float32}, dims=2) == Matrix{Float32} - @test complex_arr_type(Array{Float32}, dims=2) == Matrix{ComplexF32} - @test real_arr_type(Array{ComplexF64,2}, dims=1) == Vector{Float64} + @test real_arr_type(Array{Float32}, dims=Val(2)) == Matrix{Float32} + @test complex_arr_type(Array{Float32}, dims=Val(2)) == Matrix{ComplexF32} + @test real_arr_type(Array{ComplexF64,2}, dims=Val(1)) == Vector{Float64} @test complex_arr_type(Array{ComplexF64,1}) == Vector{ComplexF64} - @test similar_arr_type(Array{ComplexF64,1}, dims=2, dtype=Int) == Matrix{Int} - @test similar_arr_type(Array{ComplexF64}, dims=2, dtype=Int) == Matrix{Int} + @test similar_arr_type(Array{ComplexF64,1}, dims=Val(2), dtype=Int) == Matrix{Int} + @test similar_arr_type(typeof(view(ones(10,10),2:5,2:5)), dims=Val(1)) == Vector{Float64} + @test similar_arr_type(typeof(reinterpret(Int, ones(10))), dims=Val(2), dtype=Float32) == Matrix{Float32} + @test similar_arr_type(typeof(reshape(view(ones(25),1:25), 5,5)), dims=Val(1), dtype=Int) == Vector{Int} end From 2023b511dc0a8c9b6cf975144418053fea1105e7 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Tue, 18 Jun 2024 18:01:31 +0200 Subject: [PATCH 2/8] removed Manifest.toml --- Manifest.toml | 73 --------------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 Manifest.toml diff --git a/Manifest.toml b/Manifest.toml deleted file mode 100644 index 701204c..0000000 --- a/Manifest.toml +++ /dev/null @@ -1,73 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -julia_version = "1.10.4" -manifest_format = "2.0" -project_hash = "d72cac80c925125123481871f3a9328105af9ce9" - -[[deps.Artifacts]] -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" - -[[deps.CompilerSupportLibraries_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.1.1+0" - -[[deps.Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[deps.LinearAlgebra]] -deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"] -uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" - -[[deps.OffsetArrays]] -git-tree-sha1 = "e64b4f5ea6b7389f6f046d13d4896a8f9c1ba71e" -uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.14.0" - - [deps.OffsetArrays.extensions] - OffsetArraysAdaptExt = "Adapt" - - [deps.OffsetArrays.weakdeps] - Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" - -[[deps.OpenBLAS_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] -uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" - -[[deps.PaddedViews]] -deps = ["OffsetArrays"] -git-tree-sha1 = "0fac6313486baae819364c52b4f483450a9d793f" -uuid = "5432bcbf-9aad-5242-b902-cca2824c8663" -version = "0.5.12" - -[[deps.Random]] -deps = ["SHA"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[deps.SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" -version = "0.7.0" - -[[deps.Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[deps.SparseArrays]] -deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" - -[[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] -uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" - -[[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] -uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" - -[[deps.libblastrampoline_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+1" From 150f6837c1f12f0e4402aa4a77a15b08c91bdf40 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Tue, 18 Jun 2024 18:03:00 +0200 Subject: [PATCH 3/8] added .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5131d8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +Manifest.toml +test/Manifest.toml +exmaples/Manifest.toml + +docs/build/ \ No newline at end of file From ef69dce47c0ba5268648f5dfadc56de9f848cf3a Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Tue, 18 Jun 2024 20:10:37 +0200 Subject: [PATCH 4/8] changed nomenclature of similar_arr_type --- src/type_tools.jl | 46 +++++++++++++++++++++++----------------------- test/type_tools.jl | 12 +++++++----- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/type_tools.jl b/src/type_tools.jl index ad2f4cb..3599ba1 100644 --- a/src/type_tools.jl +++ b/src/type_tools.jl @@ -20,12 +20,12 @@ julia> real_arr_type(Array{ComplexF64,3}, dims=4) Array{Float64, 4} ``` """ -function real_arr_type(::Type{TA}; dims=N) where {T,N, TA<:AbstractArray{T,N}} - similar_arr_type(TA, dtype=real(eltype(TA)), dims=dims) +function real_arr_type(::Type{TA}; dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} + similar_arr_type(TA, real(eltype(TA)), dims) end -function real_arr_type(::Type{TA}; dims=1) where {TA<:AbstractArray} - similar_arr_type(TA, dtype=real(eltype(TA)), dims=dims) +function real_arr_type(::Type{TA}; dims::Val=Val(1)) where {TA<:AbstractArray} + similar_arr_type(TA, real(eltype(TA)), dims) end """ @@ -49,24 +49,24 @@ julia> complex_arr_type(Array{Float32,3},dims=1) Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) ``` """ -function complex_arr_type(::Type{TA}; dims=N) where {T,N, TA<:AbstractArray{T,N}} - similar_arr_type(TA, dtype=complex(eltype(TA)), dims=dims) +function complex_arr_type(::Type{TA}; dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} + similar_arr_type(TA, complex(eltype(TA)), dims) end -function complex_arr_type(::Type{TA}; dims=1) where {TA<:AbstractArray} - similar_arr_type(TA, dtype=complex(eltype(TA)), dims=dims) +function complex_arr_type(::Type{TA}; dims::Val=Val(1)) where {TA<:AbstractArray} + similar_arr_type(TA, complex(eltype(TA)), dims) end """ - similar_arr_type(::Type{TA}; dims=N, dtype=T) where {TA<:AbstractArray} + similar_arr_type(::Type{TA}, , T2::Type=Type{T}, N2::Val=Val(N)) where {TA<:AbstractArray} returns a similar array type but using as TA, but eltype and ndims can be changed. # Arguments + `TA`: The array type to convert to an eltype of `complex(eltype(TA))` -+ `dims`: The number of dimensions of the returned array type. Please specify this as a ::Val type to be type-stable. Default is Val(1). -+ `dtype`: The `eltype()` of the returned array type. ++ `T2`: The `eltype()` of the returned array type. Use `eltype(TA)` to keep the same type. Default is `eltype(TA)`. ++ `N2`: The number of dimensions of the returned array type. Please specify this as a ::Val type to be type-stable. Default is Val(1). # Example @@ -77,28 +77,28 @@ Vector{ComplexF64} (alias for Array{Complex{Float64}, 1}) julia> similar_arr_type(Array{ComplexF64,3}) Array{ComplexF64, 3} -julia> similar_arr_type(Array{ComplexF64,3}, dims=2, dtype=Int) +julia> similar_arr_type(Array{ComplexF64,3}, Int, Val(2)) Matrix{Int64} (alias for Array{Int64, 2}) ``` """ -function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, TA<:AbstractArray{T,N}} - typeof(similar(TA(undef, ntuple(x->0, N)), dtype, ntuple(x->0, dims))) +function similar_arr_type(::Type{TA}, T2::Type=Type{T}, N2::Val=Val(N)) where {T, N, TA<:AbstractArray{T,N}} + typeof(similar(TA(undef, ntuple(x->0, N)), T2, ntuple(x->0, N2))) end -function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, P, I, L, TA<:SubArray{T,N,P,I,L}} - similar_arr_type(P, dims=dims, dtype=dtype) +function similar_arr_type(::Type{TA}, T2::Type=Type{T}, N2::Val=Val(N)) where {T, N, P, I, L, TA<:SubArray{T,N,P,I,L}} + similar_arr_type(P, T2, N2) end -function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, P, MI, TA<:Base.ReshapedArray{T,N,P,MI}} - similar_arr_type(P, dims=dims, dtype=dtype) +function similar_arr_type(::Type{TA}, T2::Type=Type{T}, N2::Val=Val(N)) where {T, N, P, MI, TA<:Base.ReshapedArray{T,N,P,MI}} + similar_arr_type(P, T2, N2) end # note that T refers to the new type (if not explicitely specified) and therefore replaces the eltype of the array as defined by P -function similar_arr_type(::Type{TA}; dims=N, dtype=T) where {T, N, O, P, B, TA<:Base.ReinterpretArray{T,N,O,P,B}} - similar_arr_type(P, dims=dims, dtype=dtype) +function similar_arr_type(::Type{TA}, T2::Type=Type{T}, N2::Val=Val(N)) where {T, N, O, P, B, TA<:Base.ReinterpretArray{T,N,O,P,B}} + similar_arr_type(P, T2, N2) end -function similar_arr_type(::Type{TA}; dims=Val(1), dtype=eltype(TA)) where {TA<:AbstractArray} - typeof(similar(TA(undef), dtype, ntuple(x->0, dims))) +# specifically for not fully specified arrays +function similar_arr_type(::Type{TA}, T2::Type=eltype(TA), N2::Val=Val(1)) where {TA<:AbstractArray} + typeof(similar(TA(undef), T2, ntuple(x->0, N2))) end - diff --git a/test/type_tools.jl b/test/type_tools.jl index 28dfe5d..6309c84 100644 --- a/test/type_tools.jl +++ b/test/type_tools.jl @@ -1,13 +1,15 @@ @testset "Test Type Tools" begin sz = (11,12) @test real_arr_type(Array{Float32,2}) == Matrix{Float32} - @test complex_arr_type(Array{Float32,1}, dims=2) == Matrix{ComplexF32} + @test complex_arr_type(Array{Float32,1}, dims=Val(2)) == Matrix{ComplexF32} @test real_arr_type(Array{Float32}, dims=Val(2)) == Matrix{Float32} @test complex_arr_type(Array{Float32}, dims=Val(2)) == Matrix{ComplexF32} @test real_arr_type(Array{ComplexF64,2}, dims=Val(1)) == Vector{Float64} @test complex_arr_type(Array{ComplexF64,1}) == Vector{ComplexF64} - @test similar_arr_type(Array{ComplexF64,1}, dims=Val(2), dtype=Int) == Matrix{Int} - @test similar_arr_type(typeof(view(ones(10,10),2:5,2:5)), dims=Val(1)) == Vector{Float64} - @test similar_arr_type(typeof(reinterpret(Int, ones(10))), dims=Val(2), dtype=Float32) == Matrix{Float32} - @test similar_arr_type(typeof(reshape(view(ones(25),1:25), 5,5)), dims=Val(1), dtype=Int) == Vector{Int} + + @test similar_arr_type(Array{ComplexF64,1}, Int, Val(2)) == Matrix{Int} + @test similar_arr_type(Array{ComplexF64}, Float64, Val(2)) == Matrix{Float64} + @test similar_arr_type(typeof(view(ones(10,10),2:5,2:5)), Float64, Val(1)) == Vector{Float64} + @test similar_arr_type(typeof(reinterpret(Int, ones(10))), Float32, Val(2)) == Matrix{Float32} + @test similar_arr_type(typeof(reshape(view(ones(25),1:25), 5,5)), Int, Val(1)) == Vector{Int} end From fe44fa9269a5f41f4eb01344a38b882a4ecfabf3 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Wed, 19 Jun 2024 08:35:48 +0200 Subject: [PATCH 5/8] changed call convention for comoplex_arr_type and real_arr_type --- src/type_tools.jl | 8 ++++---- test/type_tools.jl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/type_tools.jl b/src/type_tools.jl index 3599ba1..0f1d1a6 100644 --- a/src/type_tools.jl +++ b/src/type_tools.jl @@ -20,11 +20,11 @@ julia> real_arr_type(Array{ComplexF64,3}, dims=4) Array{Float64, 4} ``` """ -function real_arr_type(::Type{TA}; dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} +function real_arr_type(::Type{TA}, dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} similar_arr_type(TA, real(eltype(TA)), dims) end -function real_arr_type(::Type{TA}; dims::Val=Val(1)) where {TA<:AbstractArray} +function real_arr_type(::Type{TA}, dims::Val=Val(1)) where {TA<:AbstractArray} similar_arr_type(TA, real(eltype(TA)), dims) end @@ -49,11 +49,11 @@ julia> complex_arr_type(Array{Float32,3},dims=1) Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) ``` """ -function complex_arr_type(::Type{TA}; dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} +function complex_arr_type(::Type{TA}, dims::Val=Val(N)) where {T,N, TA<:AbstractArray{T,N}} similar_arr_type(TA, complex(eltype(TA)), dims) end -function complex_arr_type(::Type{TA}; dims::Val=Val(1)) where {TA<:AbstractArray} +function complex_arr_type(::Type{TA}, dims::Val=Val(1)) where {TA<:AbstractArray} similar_arr_type(TA, complex(eltype(TA)), dims) end diff --git a/test/type_tools.jl b/test/type_tools.jl index 6309c84..56cd54b 100644 --- a/test/type_tools.jl +++ b/test/type_tools.jl @@ -1,10 +1,10 @@ @testset "Test Type Tools" begin sz = (11,12) @test real_arr_type(Array{Float32,2}) == Matrix{Float32} - @test complex_arr_type(Array{Float32,1}, dims=Val(2)) == Matrix{ComplexF32} - @test real_arr_type(Array{Float32}, dims=Val(2)) == Matrix{Float32} - @test complex_arr_type(Array{Float32}, dims=Val(2)) == Matrix{ComplexF32} - @test real_arr_type(Array{ComplexF64,2}, dims=Val(1)) == Vector{Float64} + @test complex_arr_type(Array{Float32,1}, Val(2)) == Matrix{ComplexF32} + @test real_arr_type(Array{Float32}, Val(2)) == Matrix{Float32} + @test complex_arr_type(Array{Float32}, Val(2)) == Matrix{ComplexF32} + @test real_arr_type(Array{ComplexF64,2}, Val(1)) == Vector{Float64} @test complex_arr_type(Array{ComplexF64,1}) == Vector{ComplexF64} @test similar_arr_type(Array{ComplexF64,1}, Int, Val(2)) == Matrix{Int} From 9552c1475041d4e7e814d04eca88a7c24efac918 Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Wed, 19 Jun 2024 08:44:10 +0200 Subject: [PATCH 6/8] updatd descriptions --- src/type_tools.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/type_tools.jl b/src/type_tools.jl index 0f1d1a6..dda1eeb 100644 --- a/src/type_tools.jl +++ b/src/type_tools.jl @@ -1,12 +1,12 @@ export real_arr_type, complex_arr_type, similar_arr_type """ - real_arr_type(::Type{TA}) where {TA<:AbstractArray} + real_arr_type(::Type{TA}, dims::Val = Val(N)) where {TA<:AbstractArray} returns the same array type but using `(real(eltype()))` as the element type # Arguments + `TA`: The array type to convert to an eltype of `real(eltype(TA))` -+ `dims`: The number of dimensions of the returned array type ++ `dims`: The (optional) number of dimensions of the returned array type, default is Val(N) or Val(1) depending on whether the dimensions of the array are inferrable # Example ```jldoctest @@ -16,7 +16,7 @@ Vector{Float64} (alias for Array{Float64, 1}) julia> real_arr_type(Array{ComplexF64,3}) Array{Float64, 3} -julia> real_arr_type(Array{ComplexF64,3}, dims=4) +julia> real_arr_type(Array{ComplexF64,3}, dims=Val(4)) Array{Float64, 4} ``` """ @@ -29,13 +29,13 @@ function real_arr_type(::Type{TA}, dims::Val=Val(1)) where {TA<:AbstractArray} end """ - complex_arr_type(::Type{TA}) where {TA<:AbstractArray} + complex_arr_type(::Type{TA}, dims::Val = VLa(N)) where {TA<:AbstractArray} -returns the same array type but using `(complex(eltype()))` as the element type +returns the same array type but using `(complex(eltype()))` as the element type, default is Val(N) or Val(1) depending on whether the dimensions of the array are inferrable # Arguments + `TA`: The array type to convert to an eltype of `complex(eltype(TA))` -+ `dims`: The number of dimensions of the returned array type ++ `dims`: The (optional) number of dimensions of the returned array type # Example ```jldoctest @@ -45,7 +45,7 @@ Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) julia> complex_arr_type(Array{Float32,3}) Array{ComplexF32, 3} -julia> complex_arr_type(Array{Float32,3},dims=1) +julia> complex_arr_type(Array{Float32,3}, dims=Val(1)) Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) ``` """ From 32fefc5a5f063927082efbb434d92fafeca47bfa Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Wed, 19 Jun 2024 09:23:25 +0200 Subject: [PATCH 7/8] fix in docs --- src/type_tools.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type_tools.jl b/src/type_tools.jl index dda1eeb..ee4cd2c 100644 --- a/src/type_tools.jl +++ b/src/type_tools.jl @@ -45,7 +45,7 @@ Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) julia> complex_arr_type(Array{Float32,3}) Array{ComplexF32, 3} -julia> complex_arr_type(Array{Float32,3}, dims=Val(1)) +julia> complex_arr_type(Array{Float32,3}, Val(1)) Vector{ComplexF32} (alias for Array{Complex{Float32}, 1}) ``` """ From 3c0b3f67d83985e3ee78c6d8fab45b905ac39bca Mon Sep 17 00:00:00 2001 From: RainerHeintzmann Date: Wed, 19 Jun 2024 09:25:58 +0200 Subject: [PATCH 8/8] advanced Version number to 0.7 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1c400f1..2b1665a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NDTools" uuid = "98581153-e998-4eef-8d0d-5ec2c052313d" authors = ["Rainer Heintzmann ", "Felix Wechsler "] -version = "0.6.0" +version = "0.7.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"