-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add 1.6 and 1.9 to CI * weakdep CovarianceEstimation * weakdep Tracker * weakdep ChainRulesCore * weakdep AbstractFFTs * bump
- Loading branch information
Showing
9 changed files
with
171 additions
and
125 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 |
---|---|---|
|
@@ -15,6 +15,8 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- "1.6" | ||
- "1.9" | ||
- "1" # Latest Release | ||
os: | ||
- ubuntu-latest | ||
|
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,105 @@ | ||
module AbstractFFTsExt | ||
|
||
using AbstractFFTs | ||
using NamedDims | ||
using NamedDims: wave_name, _rename | ||
|
||
|
||
################################################ | ||
# FFT | ||
|
||
for fun in (:fft, :ifft, :bfft, :rfft, :irfft, :brfft) | ||
plan_fun = Symbol(:plan_, fun) | ||
|
||
if fun in (:irfft, :brfft) # These take one more argument, a size | ||
arg, str = (:(d::Integer),), "d, " | ||
else | ||
arg, str = (), "" | ||
end | ||
|
||
@eval begin | ||
|
||
""" | ||
$($fun)(A, $($str):time => :freq, :x => :kx) | ||
Acting on a `NamedDimsArray`, this specifies to take the transform along the dimensions | ||
named `:time, :x`, and return an array with names `:freq` and `:kx` in their places. | ||
$($fun)(A, $($str):x) # => :x∿ | ||
If new names are not given, then the default is `:x => :x∿` and `:x∿ => :x`, | ||
applied to all dimensions, or to those specified as usual, e.g. `$($fun)(A, $($str)(1,2))` | ||
or `$($fun)(A, $($str):time)`. The symbol "∿" can be typed by `\\sinewave<tab>`. | ||
""" | ||
function AbstractFFTs.$fun(A::NamedDimsArray{L}, $(arg...)) where {L} | ||
data = AbstractFFTs.$fun(parent(A), $(arg...)) | ||
return NamedDimsArray(data, wave_name(L)) | ||
end | ||
|
||
function AbstractFFTs.$fun(A::NamedDimsArray{L,T,N}, $(arg...), dims) where {L,T,N} | ||
numerical_dims = dim(A, dims) | ||
data = AbstractFFTs.$fun(parent(A), $(arg...), numerical_dims) | ||
newL = wave_name(L, numerical_dims) | ||
return NamedDimsArray(data, newL) | ||
end | ||
|
||
function AbstractFFTs.$fun(A::NamedDimsArray{L,T,N}, $(arg...), p::Pair{Symbol,Symbol}, ps::Pair{Symbol,Symbol}...) where {L,T,N} | ||
numerical_dims = dim(A, (first(p), first.(ps)...)) | ||
data = AbstractFFTs.$fun(parent(A), $(arg...), numerical_dims) | ||
newL = _rename(L, p, ps...) | ||
return NamedDimsArray(data, newL) | ||
end | ||
|
||
""" | ||
F = $($plan_fun)(A, $($str):time) | ||
A∿ = F * A | ||
A ≈ F \\ A∿ ≈ inv(F) * A∿ | ||
FFT plans for `NamedDimsArray`s, identical to `A∿ = $($fun)(A, $($str):time)`. | ||
Note you cannot specify the final name, it always transforms `:time => :time∿`. | ||
And that the plan `F` stores which dimension number to act on, not which name. | ||
""" | ||
function AbstractFFTs.$plan_fun(A::NamedDimsArray, $(arg...), dims = ntuple(identity, ndims(A)); kw...) | ||
dims isa Pair && throw(ArgumentError("$($plan_fun) does not store final names, got Pair $dims")) | ||
numerical_dims = Tuple(dim(A, dims)) | ||
AbstractFFTs.$plan_fun(parent(A), $(arg...), numerical_dims; kw...) | ||
end | ||
end | ||
|
||
end | ||
|
||
for shift in (:fftshift, :ifftshift) | ||
@eval begin | ||
|
||
function AbstractFFTs.$shift(A::NamedDimsArray) | ||
data = AbstractFFTs.$shift(parent(A)) | ||
NamedDimsArray(data, dimnames(A)) | ||
end | ||
|
||
function AbstractFFTs.$shift(A::NamedDimsArray, dims) | ||
numerical_dims = dim(A, dims) | ||
data = AbstractFFTs.$shift(parent(A), numerical_dims) | ||
NamedDimsArray(data, dimnames(A)) | ||
end | ||
|
||
end | ||
end | ||
|
||
# The dimensions on which plans act are not part of the type, unfortunately | ||
for plan_type in (:Plan, :ScaledPlan) | ||
@eval function Base.:*(plan::AbstractFFTs.$plan_type, A::NamedDimsArray{L,T,N}) where {L,T,N} | ||
data = plan * parent(A) | ||
if Base.sym_in(:region, propertynames(plan)) # true for plan_fft from FFTW | ||
dims = plan.region # dims can be 1, (1,3) or 1:3 | ||
elseif Base.sym_in(:p, propertynames(plan)) | ||
dims = plan.p.region | ||
else | ||
return data | ||
end | ||
newL = ntuple(d -> d in dims ? wave_name(L[d]) : L[d], N)::NTuple{N,Symbol} | ||
# newL = wave_name(L, Tuple(dims)) # this, using compile_time_return_hack, is much slower | ||
return NamedDimsArray(data, newL) | ||
end | ||
end | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module CovarianceEstimationExt | ||
|
||
using NamedDims | ||
using CovarianceEstimation | ||
|
||
|
||
for E in (:LinearShrinkage, :SimpleCovariance, :AnalyticalNonlinearShrinkage) | ||
@eval function CovarianceEstimation.cov( | ||
estimator::$E, a::NamedDimsArray{L,T,2}; dims=1, kwargs... | ||
) where {L,T} | ||
numerical_dims = dim(a, dims) | ||
# cov returns a Symmetric matrix which needs to be rewrapped in a NamedDimsArray | ||
data = cov(estimator, parent(a); dims=numerical_dims, kwargs...) | ||
names = NamedDims.symmetric_names(L, numerical_dims) | ||
return NamedDimsArray{names}(data) | ||
end | ||
end | ||
|
||
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
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
e55c11c
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
e55c11c
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/102098
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
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: