Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension of #269: Use \circ and compose and deprecate transform #276

Merged
merged 20 commits into from
Apr 13, 2021

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Apr 11, 2021

This PR builds on #269 and takes it even further. transform is deprecated and instead \circ and its alias CompositionsBase.compose are used to construct transformed kernels.

Fixes #217.

src/deprecations.jl Outdated Show resolved Hide resolved
test/kernels/transformedkernel.jl Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
@deprecate transform(k::Kernel, t::Transform) ∘(k, t)
@deprecate transform(k::TransformedKernel, t::Transform) ∘(k.kernel, t ∘ k.transform)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in #269, currently the transformations of TransformedKernels are chained in a weird way (IMO it's a bug). Therefore the deprecation looks a bit strange as well.

devmotion and others added 2 commits April 11, 2021 17:20
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/transform/chaintransform.jl Outdated Show resolved Hide resolved
src/transform/chaintransform.jl Outdated Show resolved Hide resolved
src/transform/chaintransform.jl Outdated Show resolved Hide resolved
src/transform/chaintransform.jl Outdated Show resolved Hide resolved
test/deprecations.jl Outdated Show resolved Hide resolved
test/deprecations.jl Outdated Show resolved Hide resolved
test/deprecations.jl Outdated Show resolved Hide resolved
devmotion and others added 6 commits April 12, 2021 00:15
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/basekernels/gabor.jl Show resolved Hide resolved
docs/src/kernels.md Show resolved Hide resolved
docs/src/transform.md Outdated Show resolved Hide resolved
src/kernels/transformedkernel.jl Show resolved Hide resolved

"""
transform(k::Kernel, ρ::Real)
Compose a `kernel` with a transformation `transform` of its inputs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we repeat the mathematical definition from TransformedKernel? Since we want users to avoid using it directly this will remove the need to navigate the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like redundancy 😛 The docstring of TransformedKernel is displayed right above this docstring, so users don't have to navigate to another page. If TransformedKernel would not be exported anymore, one could remove its docstring and move the mathematical definition here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to access the docs from the REPL :) I personally almost never check API pages from the docs but overuse ?!


"""
transform(k::Kernel, ρ::AbstractVector)
If no optimized implementation exists, a [`TransformedKernel`](@ref) is created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is meant here? Do we have any optimized implementation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's basically copied from the docs of TransformedKernel but I don't think there exists an optimized implementation for any transformation yet. I assumed the intention is the same as for Distributions.truncated vs Distributions.Truncated: the former may return arbitrary types whereas the latter is restricted to Truncated which might not be the most efficient implementation for specific truncated distributions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok got it, so we leave it there as we might find some optimisation later?

@theogf
Copy link
Member

theogf commented Apr 12, 2021

This would also be great to add some examples for the docs of \circ.

@willtebbutt
Copy link
Member

I can find nothing objectionable here. Happy for this to be merged once @theogf is happy :)

@theogf
Copy link
Member

theogf commented Apr 12, 2021

For me the only problem are the docs of compose/circ which should be self contained and maybe have an example or two if we decide that it should be the main API.

@devmotion
Copy link
Member Author

I updated the docstrings and added an example.

@devmotion devmotion merged commit 589daff into master Apr 13, 2021
@devmotion devmotion deleted the pr-269 branch April 13, 2021 06:36
@st-- st-- mentioned this pull request Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify behaviour/documentation of transform()
3 participants