-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into compathelper/new_version/2024-11-06-00-14-32…
…-100-02131041769
- Loading branch information
Showing
6 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
struct NDims{ndims} end | ||
Base.ndims(::NDims{ndims}) where {ndims} = ndims | ||
|
||
NDims(ndims::Integer) = NDims{ndims}() | ||
NDims(arraytype::Type{<:AbstractArray}) = NDims(ndims(arraytype)) | ||
NDims(array::AbstractArray) = NDims(typeof(array)) |
19 changes: 15 additions & 4 deletions
19
NDTensors/src/lib/TypeParameterAccessors/test/test_similartype.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
@eval module $(gensym()) | ||
using Test: @test, @test_broken, @testset | ||
using LinearAlgebra: Adjoint | ||
using NDTensors.TypeParameterAccessors: similartype | ||
using LinearAlgebra: Adjoint, Diagonal | ||
using NDTensors.TypeParameterAccessors: NDims, similartype | ||
@testset "TypeParameterAccessors similartype" begin | ||
@test similartype(Array, Float64, (2, 2)) == Matrix{Float64} | ||
# TODO: Is this a good definition? Probably it should be left unspecified. | ||
@test similartype(Array) == Array{Any} | ||
@test similartype(Array) == Array | ||
@test similartype(Array, Float64) == Array{Float64} | ||
@test similartype(Array, (2, 2)) == Matrix | ||
@test similartype(Array, NDims(2)) == Matrix | ||
@test similartype(Array, Float64, (2, 2)) == Matrix{Float64} | ||
@test similartype(Array, Float64, NDims(2)) == Matrix{Float64} | ||
@test similartype(Adjoint{Float32,Matrix{Float32}}, Float64, (2, 2, 2)) == | ||
Array{Float64,3} | ||
@test similartype(Adjoint{Float32,Matrix{Float32}}, Float64, NDims(3)) == Array{Float64,3} | ||
@test similartype(Adjoint{Float32,Matrix{Float32}}, Float64) == Matrix{Float64} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}) == Matrix{Float32} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}, Float64) == Matrix{Float64} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}, (2, 2, 2)) == Array{Float32,3} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}, NDims(3)) == Array{Float32,3} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}, Float64, (2, 2, 2)) == | ||
Array{Float64,3} | ||
@test similartype(Diagonal{Float32,Vector{Float32}}, Float64, NDims(3)) == | ||
Array{Float64,3} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters