Skip to content

Commit f5aef04

Browse files
committed
Add Tests
1 parent 3bc3d18 commit f5aef04

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.7.1"
3+
version = "1.8.0"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -28,11 +28,12 @@ julia = "1.6"
2828
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
2929
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3030
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
31+
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
3132
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
3233
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
3334
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3435
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3536
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
3637

3738
[targets]
38-
test = ["InteractiveUtils", "Test", "BenchmarkTools", "OffsetArrays", "Statistics", "Unitful", "Aqua"]
39+
test = ["InteractiveUtils", "Test", "BenchmarkTools", "OffsetArrays", "Statistics", "Unitful", "Aqua", "ChainRulesTestUtils", "ChainRulesCore"]

ext/StaticArraysChainRulesCoreExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ module StaticArraysChainRulesCoreExt
22

33
using StaticArrays
44
# ChainRulesCore imports
5-
import ChainRulesCore: ProjectTo, Tangent, project_type, rrule
5+
import ChainRulesCore: NoTangent, ProjectTo, Tangent, project_type, rrule
66
import ChainRulesCore as CRC
77

8-
# Projecting a tuple to SMatrix leads to ChainRulesCore._projection_mismatch by default, so
8+
# Projecting a tuple to SMatrix leads to CRC._projection_mismatch by default, so
99
# overloaded here
1010
function (project::ProjectTo{<:Tangent{<:Tuple}})(dx::StaticArraysCore.SArray)
1111
dy = reshape(dx, axes(project.elements))

src/StaticArrays.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ include("flatten.jl")
133133
include("io.jl")
134134
include("pinv.jl")
135135

136-
include("chainrules.jl")
137-
138136
@static if !isdefined(Base, :get_extension) # VERSION < v"1.9-"
139137
include("../ext/StaticArraysStatisticsExt.jl")
140138
end

test/chainrules.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using StaticArrays, ChainRulesCore, ChainRulesTestUtils, Test
2+
3+
@testset "Chain Rules Integration" begin
4+
@testset "Projection" begin
5+
test_rrule(SMatrix{1, 4}, (1.0, 1.0, 1.0, 1.0))
6+
test_rrule(SMatrix{4, 1}, (1.0, 1.0, 1.0, 1.0))
7+
test_rrule(SMatrix{2, 2}, (1.0, 1.0, 1.0, 1.0))
8+
test_rrule(SVector{4}, (1.0, 1.0, 1.0, 1.0))
9+
end
10+
end

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,9 @@ if TEST_GROUP ∈ ["", "all", "group-B"]
8888
addtests("io.jl")
8989
addtests("svd.jl")
9090
addtests("unitful.jl")
91+
92+
# chain rules integration via pkg extensions is available only in Julia 1.9+
93+
if VERSION v"1.9-"
94+
addtests("chainrules.jl")
95+
end
9196
end

0 commit comments

Comments
 (0)