-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use ChangesOfVariables and InverseFunctions #212
Merged
Merged
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
31adbe8
Add ChangesOfVariables and InverseFunctions to deps
oschulz 000c83f
Replace forward by with_logabsdet_jacobian
oschulz 0c1bf48
Replace Base.inv with InverseFunctions.inverse
oschulz f6385ea
Improve deprecation scheme for forward
oschulz 0aab88b
Improve deprecation scheme for inv
oschulz e6f549d
Test forward and inv deprecations
oschulz 4c7f706
Apply suggestions from code review
oschulz 3815505
Fixes regarding with_logabsdet_jacobian and inverse
oschulz 2b93560
Fix with_logabsdet_jacobian for NamedComposition
oschulz 20e50d4
Fix deprecation of inv
oschulz fc990bb
Use inverse instead of inv for Composed
oschulz 625fbb7
Use with_logabsdet_jacobian instead of forward
oschulz 8273628
Workaround for intermittent failures in Dirichlet test
oschulz 167a26e
Use with_logabsdet_jacobian instead of forward
oschulz 8a0c658
Use with_logabsdet_jacobian instead of forward
oschulz 34f7fc6
Add rrules for combine with PartitionMask
oschulz 2f1c36d
Use inv instead of inverse for numbers
oschulz 012d90a
Apply suggestions from code review
oschulz 3fc7a43
Whitespace fix.
oschulz 045412f
Move combine rrule and add test
oschulz 7e96b8d
Apply suggestions from code review
oschulz 874b5ec
Use @test_deprecated
oschulz d9c8562
Use @test_deprecated
oschulz 5cad1e4
Use inverse instead of inv
oschulz 6ed6fa9
Use test_inverse and test_with_logabsdet_jacobian
oschulz 4fadffc
Use inverse instead of inv
oschulz 5f4d982
Increase version number to v0.9.12
oschulz fb54734
Reexport with_logabsdet_jacobian and inverse
oschulz 4b683e5
Increase package version to v0.10.0
oschulz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should probably be 0.10.0, given the magnitude of changes (and that
inv
is nowinverse
, among other things).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.
I don't have a strong opinion in it - @devmotion you did consider it non-breaking, right?
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.
I thought about it again, and I still think it is non-breaking if we add fallback definitions for
inverse
andwith_logabsdet_jacobian
:This is the only breaking change I can imagine with this PR: If a function that operates with bijectors is defined with the new API (maybe even in Bijectors) but the bijector at hand only implements the old API. This can lead to a StackOverflow error - but only if for a bijector neither the old nor the new API is implemented, and hence the implementation is broken anyway.
Otherwise,
forward
andinv
are deprecated and the other changes are merely replacements in the code and tests (to fix deprecation warnings). So even though the PR is quite large the changes itself seem small and well defined.@oschulz can you add the fallback definitions, and ideally also test them (e.g. with a dummy bijector that only implements the old API)? Then I am convinced that the PR is non-breaking.
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.
Yes, will do.
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.
I think I found a way to do that and defend against the stack overflow, so we can return a meaningful error if neither
forward
orwith_logabsdet_jacobian
is defined, by using a wrapper bijector. The same mechanism can also be used to allow defining Bijectors viawith_logabsdet_jacobian
without defininglogabsdetjac
.@devmotion, I think we we implement JuliaMath/ChangesOfVariables.jl#3 we could then immediately deprecate
logabsdetjac
as well and still keep this non-breaking, using the same wrapper trick. Let me try something ...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.
Should I remove the export of
inverse
andwith_logabsdet_jacobian
?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.
I think reexporting makes it easy to miss to which package the function actually belongs. Generally, I started to think one should be a bit more careful when it comes to reexporting since it means any breaking change of the upstream definitions seems to require a breaking release in the downstream package as well.
On the other hand, it might seem a bit strange to not export them if they are part of the API 🤷♂️
What do you think @torfjelde?
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.
I'm also in favour of this: sounds good 👍
Personally, I'm in favour of exporting. It's very rare someone does
using Bijectors
without the intention of also usinginverse
and/orwith_logabsdet_jacobian
since implementations of these is essentially the point of Bijectors.jl, hence it seems a bit weird to me if they then need to qualify the usages of these functions 🤷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.
Ok, so we keep the export? If so, this PR should be good to go from my side.
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.
Yes, let's keep it 👍