Skip to content

Commit d7c5f3f

Browse files
heliosdrmhkraemer
andauthored
FAN method (#102)
* added FAN-threshold method * parallel_false implementation done * debugged fan-methods; set up tests * minor improvements * made requested changes; resolve_scale type-stable * Parametrized types of AbstractRecurrenceMatrix for FAN * FAN by columns, not rows * exclude LOI in FAN for RP with single time series make `_computescale` type stable * allow non-square CrossRecurrenceMatrix{FAN} * avoid errors in @windowed RecurrenceMatrix{FAN} etc. * adapt deprecate.jl and tests to parametric types * generalize dispatch on AbstractDataset * redefine FixedRange > WithinRange and FixedAmount > NeighborNumber Co-authored-by: K. Hauke Kraemer <[email protected]>
1 parent 1d45308 commit d7c5f3f

File tree

8 files changed

+192
-86
lines changed

8 files changed

+192
-86
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "RecurrenceAnalysis"
22
uuid = "639c3291-70d9-5ea2-8c5b-839eba1ee399"
33
repo = "https://github.com/JuliaDynamics/RecurrenceAnalysis.jl.git"
4-
version = "1.3.2"
4+
version = "1.4.0"
55

66
[deps]
77
DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f"
@@ -15,7 +15,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1515
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
1616

1717
[compat]
18-
DelayEmbeddings = "0.1,0.2,0.3,1"
18+
DelayEmbeddings = "1"
1919
Distances = "0.8, 0.9, 0.10"
2020
StaticArrays = "0.8,0.9,0.10,0.11,0.12, 1.0"
2121
UnicodePlots = "0.3,1"

src/RecurrenceAnalysis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ end
2323

2424

2525
export RecurrenceMatrix, CrossRecurrenceMatrix, JointRecurrenceMatrix,
26-
AbstractRecurrenceMatrix
26+
AbstractRecurrenceMatrix, WithinRange, NeighborNumber, FAN
2727

2828
export embed,
2929
reconstruct,

src/deprecate.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
function RecurrenceMatrix(x::AbstractMatrix, ε; kwargs...)
2-
@warn "`RecurrenceMatrix(x::AbstractMatrix, ε; kwargs...)` is deprecated, use `RecurrenceMatrix(Dataset(x), ε; kwargs...)`"
3-
RecurrenceMatrix(Dataset(x), ε; kwargs...)
4-
end
5-
6-
for call in (:CrossRecurrenceMatrix, :JointRecurrenceMatrix)
7-
@eval function ($call)(x::AbstractMatrix, y, ε; kwargs...)
8-
@warn string("`", $call, "(x::AbstractMatrix, y, ε; kwargs...)` is deprecated, use `", $call, "(Dataset(x), y, ε; kwargs...)`")
9-
($call)(Dataset(x), y, ε; kwargs...)
10-
end
11-
12-
@eval function ($call)(x, y::AbstractMatrix, ε; kwargs...)
13-
@warn string("`", $call, "(x, y::AbstractMatrix, ε; kwargs...)` is deprecated, use `", $call, "(x, Dataset(y), ε; kwargs...)`")
14-
($call)(x, Dataset(y), ε; kwargs...)
1+
for T in (:WithinRange, :NeighborNumber)
2+
@eval function RecurrenceMatrix{$T}(x::AbstractMatrix, ε; kwargs...)
3+
@warn string("`RecurrenceMatrix{", $T, "}(x::AbstractMatrix, ε; kwargs...)` is deprecated, use `RecurrenceMatrix{", $T, "}(Dataset(x), ε; kwargs...)`")
4+
RecurrenceMatrix{$T}(Dataset(x), ε; kwargs...)
155
end
166

17-
@eval function ($call)(x::AbstractMatrix, y::AbstractMatrix, ε; kwargs...)
18-
@warn string("`", $call, "(x::AbstractMatrix, y::AbstractMatrix, ε; kwargs...)` is deprecated, use `", $call, "(Dataset(x), Dataset(y), ε; kwargs...)`")
19-
($call)(Dataset(x), Dataset(y), ε; kwargs...)
7+
for call in (:CrossRecurrenceMatrix, :JointRecurrenceMatrix)
8+
@eval function $call{$T}(x::AbstractMatrix, y, ε; kwargs...)
9+
@warn string("`", $call, "{", $T, "}(x::AbstractMatrix, y, ε; kwargs...)` is deprecated, use `", $call, "{", $T, "}(Dataset(x), y, ε; kwargs...)`")
10+
$call{$T}(Dataset(x), y, ε; kwargs...)
11+
end
12+
13+
@eval function $call{$T}(x, y::AbstractMatrix, ε; kwargs...)
14+
@warn string("`", $call, "{", $T, "}(x, y::AbstractMatrix, ε; kwargs...)` is deprecated, use `", $call, "{", $T, "}(x, Dataset(y), ε; kwargs...)`")
15+
$call{$T}(x, Dataset(y), ε; kwargs...)
16+
end
17+
18+
@eval function $call{$T}(x::AbstractMatrix, y::AbstractMatrix, ε; kwargs...)
19+
@warn string("`", $call, "{", $T, "}(x::AbstractMatrix, y::AbstractMatrix, ε; kwargs...)` is deprecated, use `", $call, "{", $T, "}(Dataset(x), Dataset(y), ε; kwargs...)`")
20+
$call{$T}(Dataset(x), Dataset(y), ε; kwargs...)
21+
end
2022
end
2123
end
22-

src/distance_matrix.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Create a matrix with the distances between each pair of points of the
88
time series `x` and `y` using `metric`.
99
10-
The time series `x` and `y` can be `Dataset`s or vectors or matrices with data points
10+
The time series `x` and `y` can be `AbstractDataset`s or vectors or matrices with data points
1111
in rows.
1212
The data point dimensions (or number of columns) must be the same for `x` and `y`.
1313
The returned value is a `n×m` matrix, with `n` being the length (or number of rows)
@@ -34,7 +34,7 @@ distancematrix(x, y, metric::String, parallel = size(x)[1] > 500) = distancematr
3434

3535
const MAXDIM = 9
3636
function distancematrix(x::Tx, y::Ty, metric::Metric=DEFAULT_METRIC, parallel = size(x)[1] > 500) where
37-
{Tx<:Union{AbstractMatrix, Dataset}} where {Ty<:Union{AbstractMatrix, Dataset}}
37+
{Tx<:Union{AbstractMatrix, AbstractDataset}} where {Ty<:Union{AbstractMatrix, AbstractDataset}}
3838
sx, sy = size(x), size(y)
3939
@assert sx[2] == sy[2] """
4040
The dimensions of the data points in `x` and `y` must be equal!
@@ -54,8 +54,8 @@ end
5454
_distancematrix(x::AbstractMatrix, y::AbstractMatrix, metric::Metric, ::Val{false}) = pairwise(metric, x', y', dims=2)
5555

5656
# First we define the serial versions of the functions.
57-
# Core function for Datasets
58-
function _distancematrix(x::Dataset{S,Tx}, y::Dataset{S,Ty},
57+
# Core function for AbstractDatasets
58+
function _distancematrix(x::AbstractDataset{S,Tx}, y::AbstractDataset{S,Ty},
5959
metric::Metric, ::Val{false}) where {S, Tx, Ty}
6060

6161
x = x.data
@@ -71,7 +71,7 @@ end
7171

7272
# Now, we define the parallel versions.
7373

74-
function _distancematrix(x::Dataset{S,Tx}, y::Dataset{S,Ty},
74+
function _distancematrix(x::AbstractDataset{S,Tx}, y::AbstractDataset{S,Ty},
7575
metric::Metric, ::Val{true}) where {S, Tx, Ty}
7676

7777
x = x.data
@@ -118,7 +118,7 @@ function _distancematrix(x::Vector{T}, metric::Metric, ::Val{false}) where T
118118

119119
end
120120

121-
function _distancematrix(x::Dataset{S, T}, metric::Metric, ::Val{false}) where T where S
121+
function _distancematrix(x::AbstractDataset{S, T}, metric::Metric, ::Val{false}) where T where S
122122
d = zeros(T, length(x), length(x))
123123

124124
for j in 1:length(x)
@@ -175,7 +175,7 @@ function _distancematrix(x::Vector{T}, metric::Metric, ::Val{true}) where T
175175

176176
end
177177

178-
function _distancematrix(x::Dataset{S, T}, metric::Metric, ::Val{true}) where T where S
178+
function _distancematrix(x::AbstractDataset{S, T}, metric::Metric, ::Val{true}) where T where S
179179
d = zeros(T, length(x), length(x))
180180

181181
Threads.@threads for k in partition_indices(length(x))

0 commit comments

Comments
 (0)