Skip to content

Commit

Permalink
define Distances._result_type
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Nov 27, 2022
1 parent eca2365 commit 91f2213
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SpectralDistances"
uuid = "2b0dec9d-f767-4f95-9e73-7df56487de68"
authors = ["Fredrik Bagge Carlson <[email protected]>"]
version = "0.1.14"
version = "0.1.15"

[deps]
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
Expand Down
2 changes: 2 additions & 0 deletions src/losses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Base.Broadcast.broadcastable(p::Identity) = Ref(p)
Base.Broadcast.broadcastable(p::Log) = Ref(p)
magnitude(d) = Identity()

Distances.result_type(::AbstractDistance, a, b) = promote_type(eltype(a), eltype(b))


evaluate(d::DistanceCollection,x,y;kwargs...) = sum(evaluate(d,x,y;kwargs...) for d in d)
Base.:(+)(d::AbstractDistance...) = d
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ using SpectralDistances: ngradient, nhessian, njacobian, polyconv, hproots, rev

D2,S = complete_distmat(D0, W)

@test (norm(D-D2)/norm(D)) < 1e-5
@test (norm(W .* (D-D2))/norm(D)) < 1e-5
@test (norm(D-D2)/norm(D)) < 1e-4
@test (norm(W .* (D-D2))/norm(D)) < 1e-4

X = Diagonal(sqrt.(S.S))*S.Vt

Expand Down

0 comments on commit 91f2213

Please sign in to comment.