Skip to content

Commit c38b148

Browse files
Fix identity_element on TranslationGroup with StaticArrays types (#35)
* Fix identity_element on TranslationGroup with StaticArrays types * fix test * fix --------- Co-authored-by: Ronny Bergmann <[email protected]>
1 parent 679742a commit c38b148

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

NEWS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ All notable Changes to the Julia package `LieGroups.jl` will be documented in th
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [0.1.1] unreleased
8+
## [0.1.1] 2025-05-05
9+
10+
### Added
11+
12+
* `identity_element` on `TranslationGroup` supports now `StaticArrays.jl` types.
913

1014
### Changed
1115

1216
* the tutorials are now rendered with `quarto` using the [`QuartoNotebookRunner.jl`](https://github.com/PumasAI/QuartoNotebookRunner.jl) and are hence purely julia based.
1317

18+
### Fixed
19+
20+
* `identity_element` on `TranslationGroup` no longer accepts a number as a second argument (it accepts number type instead).
21+
1422
## [0.1.0] 2025-04-22
1523

1624
Everything denoted by “formerly” refers to the previous name in [`Manifolds.jl`](https://juliamanifolds.github.io/Manifolds.jl/stable/).

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LieGroups"
22
uuid = "6774de46-80ba-43f8-ba42-e41071ccfc5f"
33
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Yueh-Hua Tu", "Olivier Verdier <[email protected]>"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/group_operations/addition_operation.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,18 @@ identity_element(::LieGroup{𝔽,AdditionGroupOperation}) where {𝔽}
140140

141141
function identity_element(
142142
::LieGroup{𝔽,AdditionGroupOperation}, ::Type{T}
143-
) where {𝔽,T<:Union{Number,AbstractArray{0,<:Number}}}
143+
) where {𝔽,T<:Union{Number,AbstractArray{<:Number,0}}}
144144
return zero(T)
145145
end
146146
function identity_element(
147147
::LieGroup{𝔽,AdditionGroupOperation}, ::Type{Array{T,0}}
148148
) where {𝔽,T<:Number}
149149
return fill(zero(T))
150150
end
151-
function identity_element(::LieGroup{𝔽,AdditionGroupOperation}, e::Number) where {𝔽}
152-
return zero(e)
151+
function identity_element(
152+
::LieGroup{𝔽,AdditionGroupOperation}, T::Type{<:StaticArray}
153+
) where {𝔽}
154+
return zero(T)
153155
end
154156

155157
@doc "$(_doc_identity_element_add)"

test/groups/test_translation_group.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LieGroups, Random, Test
1+
using LieGroups, Random, Test, StaticArrays
22

33
s = joinpath(@__DIR__, "..", "LieGroupsTestSuite.jl")
44
!(s in LOAD_PATH) && (push!(LOAD_PATH, s))
@@ -69,4 +69,9 @@ begin
6969
test_group_action(A, properties2, expectations2)
7070
end
7171
end
72+
73+
@testset "StaticArrays" begin
74+
@test identity_element(G, SVector{3,Float64}) === zero(SVector{3,Float64})
75+
@test identity_element(G, MVector{3,Float64}) == zero(MVector{3,Float64})
76+
end
7277
end

test/operations/test_addition_operation.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ s = joinpath(@__DIR__, "../LieGroupsTestSuite.jl")
44
!(s in LOAD_PATH) && (push!(LOAD_PATH, s))
55
using LieGroupsTestSuite
66

7+
using StaticArrays
8+
79
@testset "Addition Operation" begin
810
@testset "Base.:+ and Base.:- with the Identity" begin
911
e = Identity(AdditionGroupOperation())
@@ -17,6 +19,8 @@ using LieGroupsTestSuite
1719
@test (e - e) === e
1820
@test (-e) === e
1921
G = LieGroup(LieGroupsTestSuite.DummyManifold(), AdditionGroupOperation())
20-
@test identity_element(G, 1.0) == 0.0
22+
@test identity_element(G, Float64) == 0.0
23+
@test identity_element(G, Array{Float64,0}) == fill(0.0)
24+
@test identity_element(G, SArray{Tuple{},Float64}) == @SArray fill(0.0)
2125
end
2226
end

0 commit comments

Comments
 (0)