-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
export getparam, @unpack_params | ||
|
||
|
||
""" | ||
abstract type DomainParams | ||
Abstract type for multidomain i.e. time, frequency domain models. | ||
This is to extend existing models that are just definedin the image and | ||
visibility domain and automatically extend them to time and frequency domain. | ||
The interface is simple and to extend this with your own time and frequency models, | ||
most users will just need to define | ||
```julia | ||
struct MyDomainParam <: DomainParams end | ||
function build_params(param::MyDomainParam, p) | ||
... | ||
end | ||
where `p` is the point where the model will be evaluated at. For an | ||
example see the [`TaylorSpectralModel`](@ref). | ||
For a model parameterized with a `<:DomainParams` the a use should access | ||
the parameters with [`getparam`](@ref) or the `@unpack_params` macro. | ||
``` | ||
""" | ||
abstract type DomainParams end | ||
|
||
abstract type FrequencyParams <: DomainParams end | ||
abstract type TimeParams <: DomainParams end | ||
|
||
|
||
""" | ||
getparam(m, s::Symbol, p) | ||
Gets the parameter value `s` from the model `m` evaluated at the domain `p`. | ||
This is similar to getproperty, but allows for the parameter to be a function of the | ||
domain. Essentially is `m.s <: DomainParams` then `m.s` is evaluated at the parameter `p`. | ||
If `m.s` is not a subtype of `DomainParams` then `m.s` is returned. | ||
!!! warn | ||
This feature is experimental and is not considered part of the public stable API. | ||
""" | ||
@inline function getparam(m, s::Symbol, p) | ||
ps = getproperty(m, s) | ||
return build_param(ps, p) | ||
end | ||
@inline function getparam(m, ::Val{s}, p) where {s} | ||
return getparam(m, s, p) | ||
end | ||
|
||
@inline function build_param(param::Any, p) | ||
return param | ||
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
7a8c438
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
7a8c438
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/122188
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: