-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove FillArrays dependency by implementing custom
OneElement
(#453)
* Remove FillArrays dep by implementing custom `OneElement` * Clean up * Fixes
- Loading branch information
Showing
17 changed files
with
110 additions
and
47 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
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
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
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,41 @@ | ||
using DifferentiationInterface: OneElement, basis | ||
using LinearAlgebra | ||
using StaticArrays, JLArrays | ||
using Test | ||
|
||
@testset "OneElement" begin | ||
a = rand(Float32, 3) | ||
i = eachindex(a)[2] | ||
oe = OneElement(i, 2.0f0, a) | ||
@test eltype(oe) == Float32 | ||
@test oe == [0, 2, 0] | ||
|
||
a = rand(Float64, 3, 3) | ||
i = eachindex(a)[4] | ||
oe = OneElement(i, 2.0, a) | ||
@test eltype(oe) == Float64 | ||
@test oe == [0 2 0; 0 0 0; 0 0 0] | ||
|
||
a = Diagonal(ones(3)) | ||
i = eachindex(a)[4] | ||
oe = OneElement(i, 2.0, a) | ||
@test oe == [0 2 0; 0 0 0; 0 0 0] | ||
end | ||
|
||
@testset "Basis" begin | ||
b_ref = [0, 1, 0] | ||
@test basis(rand(3), 2) isa Vector | ||
@test basis(rand(3), 2) == b_ref | ||
@test basis(jl(rand(3)), 2) isa JLArray | ||
@test all(basis(jl(rand(3)), 2) .== b_ref) | ||
@test basis(@SVector(rand(3)), 2) isa SVector | ||
@test basis(@SVector(rand(3)), 2) == b_ref | ||
|
||
b_ref = [0 1 0; 0 0 0; 0 0 0] | ||
@test basis(rand(3, 3), 4) isa Matrix | ||
@test basis(rand(3, 3), 4) == b_ref | ||
@test basis(jl(rand(3, 3)), 4) isa JLArray | ||
@test all(basis(jl(rand(3, 3)), 4) .== b_ref) | ||
@test basis(@SMatrix(rand(3, 3)), 4) isa SMatrix | ||
@test basis(@SMatrix(rand(3, 3)), 4) == b_ref | ||
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