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

Resolve test_approx ambiguities #253

Merged
merged 6 commits into from
Jul 19, 2022
Merged

Resolve test_approx ambiguities #253

merged 6 commits into from
Jul 19, 2022

Conversation

mzgubic
Copy link
Member

@mzgubic mzgubic commented Jul 8, 2022

Closes #252

Comment on lines 92 to 99
test_approx(
Tangent{Tuple{Float64,Float64}}(ZeroTangent(), NoTangent()),
NoTangent(),
)
test_approx(
NoTangent(),
Tangent{Tuple{Float64,Float64}}(ZeroTangent(), NoTangent()),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we want this? I think we do

Copy link
Member

Choose a reason for hiding this comment

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

I don't really think we do. Why do we?
I guess the argument can be made that something which is partially ZeroTangent and partially NoTangent is effectively net NoTangent
This definately works and makes sense for addition. If perturbing an input is an error along one code-path but fine in the other it is an error.
Then overall perturbing it is an error.

julia> NoTangent() + ZeroTangent()
NoTangent()

But I am not sure how to think about it for a tuple

Copy link
Member Author

Choose a reason for hiding this comment

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

In practice I think what matters is that NoTangent() is the same as Tangent of just NoTangent()s.

E.g. the choice similar to the one we made in

julia> rand_tangent((1, 2))
NoTangent()

I added on the ZeroTangent on purely practical grounds, since they are effectively the same. But I can't justify it either, so we can push that decision down the road when we deal with automating testing a bit better, and restrict to NoTangent for now.

Does that sound good to merge?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good

src/check_result.jl Outdated Show resolved Hide resolved
Comment on lines 92 to 99
test_approx(
Tangent{Tuple{Float64,Float64}}(ZeroTangent(), NoTangent()),
NoTangent(),
)
test_approx(
NoTangent(),
Tangent{Tuple{Float64,Float64}}(ZeroTangent(), NoTangent()),
)
Copy link
Member

Choose a reason for hiding this comment

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

I don't really think we do. Why do we?
I guess the argument can be made that something which is partially ZeroTangent and partially NoTangent is effectively net NoTangent
This definately works and makes sense for addition. If perturbing an input is an error along one code-path but fine in the other it is an error.
Then overall perturbing it is an error.

julia> NoTangent() + ZeroTangent()
NoTangent()

But I am not sure how to think about it for a tuple

@mcabbott
Copy link
Member

Fixes the example from #229 too:

julia> ChainRulesTestUtils.test_approx(Tangent{Int}(; x=1), ZeroTangent())
false

(jl_rp9LKs) pkg> st
Status `/private/var/folders/yq/4p2zwd614y59gszh7y9ypyhh0000gn/T/jl_rp9LKs/Project.toml`
  [cdddcdb0] ChainRulesTestUtils v1.8.2 `https://github.com/JuliaDiff/ChainRulesTestUtils.jl#mz/testapprox`

mcabbott added a commit to mcabbott/ChainRules.jl that referenced this pull request Jul 14, 2022
mcabbott added a commit to mcabbott/ChainRules.jl that referenced this pull request Jul 14, 2022
mcabbott added a commit to JuliaDiff/ChainRules.jl that referenced this pull request Jul 14, 2022
* getindex for tuples

* sum for tuples

* repeated indices in getindex, etc

* add colon case

* tidy, use Tanget

* first, tail

* simplify

* Apply 2 suggestions

Co-authored-by: Frames Catherine White <oxinabox@ucc.asn.au>

* skip a test until JuliaDiff/ChainRulesTestUtils.jl#253, bump version

* comment on Zygote

Co-authored-by: Frames Catherine White <oxinabox@ucc.asn.au>
mzgubic and others added 3 commits July 18, 2022 18:30
Co-authored-by: Frames Catherine White <lyndon.white@invenialabs.co.uk>
@codecov-commenter
Copy link

Codecov Report

Merging #253 (6a3fc74) into main (4050989) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #253   +/-   ##
=======================================
  Coverage   93.41%   93.41%           
=======================================
  Files          12       12           
  Lines         334      334           
=======================================
  Hits          312      312           
  Misses         22       22           
Impacted Files Coverage Δ
src/check_result.jl 90.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4050989...6a3fc74. Read the comment docs.

@mzgubic mzgubic merged commit 5b9ec32 into main Jul 19, 2022
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.

test_approx ambiguities
4 participants