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

use hasproperty, not hasfield for ProjectTo #414

Merged
merged 2 commits into from
Jul 26, 2021
Merged

use hasproperty, not hasfield for ProjectTo #414

merged 2 commits into from
Jul 26, 2021

Conversation

oxinabox
Copy link
Member

In nested AD using hasfield makes Zygote sad.
Also it is ugly compared to hasproperty

I thought I caught all uses of this in #391
but one must have been missed -- it was a huge PR.

@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2021

Codecov Report

Merging #414 (b0f2d77) into master (d68a5b8) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #414      +/-   ##
==========================================
+ Coverage   92.12%   92.25%   +0.12%     
==========================================
  Files          14       14              
  Lines         775      775              
==========================================
+ Hits          714      715       +1     
+ Misses         61       60       -1     
Impacted Files Coverage Δ
src/ChainRulesCore.jl 100.00% <ø> (ø)
src/projection.jl 95.56% <100.00%> (+0.49%) ⬆️

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 d68a5b8...b0f2d77. Read the comment docs.

Copy link
Member

@willtebbutt willtebbutt left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. Could you please leave a comment saying why getproperty is used rather than hasfield though?

Separate question: would @non_differentiableing hasfield not solve the problem?

@oxinabox
Copy link
Member Author

Could you please leave a comment saying why getproperty is used rather than hasfield though?

It is less code, though.
It is simply the most concise way to achieve the goal -- we have getproperty overloading for a reason.

I wanted this code before I knew it fixed Zygote.

Separate question: would @non_differentiableing hasfield not solve the problem?

I assume so, but I don't know, didn't try.
Not actually sure why changing to hasproperty fixes it.

@oxinabox oxinabox merged commit 424a0b7 into master Jul 26, 2021
@oxinabox oxinabox deleted the ox/zygotefix branch July 26, 2021 18:01
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.

3 participants