-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from JuliaNLSolvers/mbaran/check-error-type
check_manifold_point and check_tangent_vector throw right error types
- Loading branch information
Showing
6 changed files
with
140 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ManifoldsBase" | ||
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb" | ||
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"] | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
|
||
[deps] | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
|
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,34 @@ | ||
using ManifoldsBase | ||
using Test | ||
|
||
struct ErrorTestManifold <: Manifold end | ||
|
||
function ManifoldsBase.check_manifold_point(::ErrorTestManifold, x) | ||
if any(u -> u < 0, x) | ||
return DomainError(x, "<0") | ||
end | ||
return nothing | ||
end | ||
function ManifoldsBase.check_tangent_vector(M::ErrorTestManifold, x, v) | ||
mpe = check_manifold_point(M, x) | ||
mpe === nothing || return mpe | ||
if any(u -> u < 0, v) | ||
return DomainError(v, "<0") | ||
end | ||
return nothing | ||
end | ||
|
||
@testset "Domain errors" begin | ||
M = ErrorTestManifold() | ||
@test isa(check_manifold_point(M, [-1, 1]), DomainError) | ||
@test check_manifold_point(M, [1, 1]) === nothing | ||
@test !is_manifold_point(M, [-1, 1]) | ||
@test is_manifold_point(M, [1, 1]) | ||
@test_throws DomainError is_manifold_point(M, [-1, 1], true) | ||
|
||
@test isa(check_tangent_vector(M, [1, 1], [-1, 1]), DomainError) | ||
@test check_tangent_vector(M, [1, 1], [1, 1]) === nothing | ||
@test !is_tangent_vector(M, [1, 1], [-1, 1]) | ||
@test is_tangent_vector(M, [1, 1], [1, 1]) | ||
@test_throws DomainError is_tangent_vector(M, [1, 1], [-1, 1], true) | ||
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
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
9c2f41c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
9c2f41c
There was a problem hiding this comment.
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/5881
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 Julia TagBot is installed, or can be done manually through the github interface, or via: