-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing (and fixing) handling of AbstractVector{AbstractVector{T}} in…
…puts (#370) * Fix input types, improve readability * Add missing bit * Add doc string * Fix mistake * Add docstring to docs * Reformulate * Add test * Potential fix for Delta distance * Fix fbm * Further Delta fixes * Formatter * Remove old Delta implementation * Make interface more specific * Formatter * Bump patch
- Loading branch information
Showing
4 changed files
with
23 additions
and
15 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
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 |
---|---|---|
@@ -1,19 +1,10 @@ | ||
# Delta is not following the PreMetric rules since d(x, x) == 1 | ||
struct Delta <: Distances.UnionPreMetric end | ||
|
||
@inline function Distances._evaluate(::Delta, a::AbstractVector, b::AbstractVector) | ||
@boundscheck if length(a) != length(b) | ||
throw( | ||
DimensionMismatch( | ||
"first array has length $(length(a)) which does not match the length of the " * | ||
"second, $(length(b)).", | ||
), | ||
) | ||
end | ||
return a == b | ||
end | ||
|
||
Distances.result_type(::Delta, Ta::Type, Tb::Type) = Bool | ||
|
||
@inline Distances.eval_op(::Delta, a::Real, b::Real) = a == b | ||
@inline Distances.eval_reduce(::Delta, a, b) = a && b | ||
@inline Distances.eval_start(::Delta, a, b) = true | ||
@inline (dist::Delta)(a::AbstractArray, b::AbstractArray) = Distances._evaluate(dist, a, b) | ||
@inline (dist::Delta)(a::Number, b::Number) = a == b | ||
|
||
Distances.result_type(::Delta, Ta::Type, Tb::Type) = Bool |
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
9f708d0
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
9f708d0
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/46218
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: