Skip to content

Commit

Permalink
Add Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Dec 10, 2023
1 parent 3bc3d18 commit f5aef04
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticArrays"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.7.1"
version = "1.8.0"

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

[targets]
test = ["InteractiveUtils", "Test", "BenchmarkTools", "OffsetArrays", "Statistics", "Unitful", "Aqua"]
test = ["InteractiveUtils", "Test", "BenchmarkTools", "OffsetArrays", "Statistics", "Unitful", "Aqua", "ChainRulesTestUtils", "ChainRulesCore"]
4 changes: 2 additions & 2 deletions ext/StaticArraysChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module StaticArraysChainRulesCoreExt

using StaticArrays
# ChainRulesCore imports
import ChainRulesCore: ProjectTo, Tangent, project_type, rrule
import ChainRulesCore: NoTangent, ProjectTo, Tangent, project_type, rrule
import ChainRulesCore as CRC

# Projecting a tuple to SMatrix leads to ChainRulesCore._projection_mismatch by default, so
# Projecting a tuple to SMatrix leads to CRC._projection_mismatch by default, so
# overloaded here
function (project::ProjectTo{<:Tangent{<:Tuple}})(dx::StaticArraysCore.SArray)
dy = reshape(dx, axes(project.elements))
Expand Down
2 changes: 0 additions & 2 deletions src/StaticArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ include("flatten.jl")
include("io.jl")
include("pinv.jl")

include("chainrules.jl")

@static if !isdefined(Base, :get_extension) # VERSION < v"1.9-"
include("../ext/StaticArraysStatisticsExt.jl")
end
Expand Down
10 changes: 10 additions & 0 deletions test/chainrules.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using StaticArrays, ChainRulesCore, ChainRulesTestUtils, Test

@testset "Chain Rules Integration" begin
@testset "Projection" begin
test_rrule(SMatrix{1, 4}, (1.0, 1.0, 1.0, 1.0))
test_rrule(SMatrix{4, 1}, (1.0, 1.0, 1.0, 1.0))
test_rrule(SMatrix{2, 2}, (1.0, 1.0, 1.0, 1.0))
test_rrule(SVector{4}, (1.0, 1.0, 1.0, 1.0))
end
end
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,9 @@ if TEST_GROUP ∈ ["", "all", "group-B"]
addtests("io.jl")
addtests("svd.jl")
addtests("unitful.jl")

# chain rules integration via pkg extensions is available only in Julia 1.9+
if VERSION v"1.9-"
addtests("chainrules.jl")
end
end

2 comments on commit f5aef04

@ChrisRackauckas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/97115

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.8.0 -m "<description of version>" f5aef042fe13b8cd85b1b54ea1ec7e0b82e89349
git push origin v1.8.0

Please sign in to comment.