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

rename differentials #353

Merged
merged 12 commits into from
May 19, 2021
Merged

rename differentials #353

merged 12 commits into from
May 19, 2021

Conversation

mzgubic
Copy link
Member

@mzgubic mzgubic commented May 13, 2021

Closes #305

I've only renamed the definitions here so we can finalise our discussion on what to call different things.

Once we agree, I'll make the rest of the changes.

Edit:

The final list is:

  • AbstractDifferential -> AbstractTangent
  • Composite{T} -> Tangent{T}
  • Zero -> ZeroTangent
  • DoesNotExist -> NoTangent

And I've left One for another PR since it was causing CI to fail on Julia 1.0 and Julia 1.5

@@ -112,7 +112,7 @@ but it should do this more efficently than simply doing this directly.
Most operations on an `InplaceableThunk` treat it just like a normal `Thunk`;
and destroy its inplacability.
"""
struct InplaceableThunk{T<:Thunk, F} <: AbstractThunk
struct InplaceableThunkedTangent{T<:Thunk, F} <: AbstractThunk
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems too long and I've changed it only to highlight the inconsistency we get if we keep it as InplaceableThunk.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we shouldn't use the Tangent suffix for Thunks?

Copy link
Member Author

Choose a reason for hiding this comment

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

How about InplaceableTangent?

Copy link
Contributor

Choose a reason for hiding this comment

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

Two reasons against that:

  • hides arguably the more important info for handling this object (that it is a thunk)
  • many tangents are "inplaceable" without being this type (so having something named InplaceableTangent is confusing)

Personally I prefer both the current name and the more verbose name

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've changed it back to the current name. Are there any other open questions or are we happy with this? I'll go ahead and open follow up PRs everywhere

@@ -3,7 +3,7 @@
The Differential which is the multiplicative identity.
Basically, this represents `1`.
"""
struct One <: AbstractDifferential end
struct OneTangent <: AbstractTangent end
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 to be consistent with ZeroTangent? It seems to be used very rarely anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I think we want to delete this. #354
Can we try deprecating it in favour of true and see if that breaks anything on our reverse dependency tests?

@deprecate One() true

@oxinabox
Copy link
Member

oxinabox commented May 13, 2021

We need to use @deprecate_binding to deprecate these.
@deprecate_binding is the best form of deprecation.

It should be all
@deprecate_binding Zero ZeroTangent

@@ -71,7 +71,7 @@ arguments.
end
```
"""
struct DoesNotExist <: AbstractZero end
struct NoPossibleTangent <: AbstractZero end
Copy link
Contributor

Choose a reason for hiding this comment

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

Shorter and means the same thing?

Suggested change
struct NoPossibleTangent <: AbstractZero end
struct NoTangent <: AbstractZero end

Copy link
Member

Choose a reason for hiding this comment

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

Arguably means a different thing, but might still be good

@mzgubic
Copy link
Member Author

mzgubic commented May 14, 2021

@simeonschaub @devmotion @sethaxen @mcabbott thoughts/opinions?

Copy link
Member

@simeonschaub simeonschaub left a comment

Choose a reason for hiding this comment

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

I didn't mind the old names too much, but I am fine with adopting these new names.

@codecov-commenter
Copy link

codecov-commenter commented May 17, 2021

Codecov Report

Merging #353 (cf4d39a) into master (b98e624) will not change coverage.
The diff coverage is 97.74%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #353   +/-   ##
=======================================
  Coverage   90.03%   90.03%           
=======================================
  Files          14       14           
  Lines         542      542           
=======================================
  Hits          488      488           
  Misses         54       54           
Impacted Files Coverage Δ
src/ChainRulesCore.jl 100.00% <ø> (ø)
src/differentials/notimplemented.jl 72.00% <ø> (ø)
src/differentials/thunks.jl 64.00% <ø> (ø)
src/rules.jl 100.00% <ø> (ø)
src/differentials/abstract_differential.jl 66.66% <50.00%> (ø)
src/differentials/composite.jl 83.05% <95.45%> (ø)
src/differential_arithmetic.jl 96.72% <100.00%> (ø)
src/differentials/abstract_zero.jl 94.11% <100.00%> (ø)
src/differentials/one.jl 83.33% <100.00%> (ø)
src/rule_definition_tools.jl 96.89% <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 b98e624...cf4d39a. Read the comment docs.

@mzgubic mzgubic changed the title WIP: rename differentials rename differentials May 17, 2021
@mzgubic
Copy link
Member Author

mzgubic commented May 17, 2021

One had some issues on Julia 1.5 and 1.0, let's deprecate that in a separate PR.

Copy link
Contributor

@nickrobinson251 nickrobinson251 left a comment

Choose a reason for hiding this comment

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

So the full list of renaming is:

  • AbstractDifferential -> AbstractTangent
  • Composite{T} -> Tangent{T}
  • Zero -> ZeroTangent
  • DoesNotExist -> NoTangent

Thunk and InplaceableThunk are unchanged.

And the old names are deprecated, not yet removed, so this is non-breaking.

Should we have tests that these things are successfully deprecated (e.g. just @test Zero() === ZeroTangent())?

I'm okay with this renaming :)

EDIT: What's happening with One?

src/deprecated.jl Outdated Show resolved Hide resolved
@mzgubic
Copy link
Member Author

mzgubic commented May 18, 2021

So the full list of renaming is:

  • AbstractDifferential -> AbstractTangent
  • Composite{T} -> Tangent{T}
  • Zero -> ZeroTangent
  • DoesNotExist -> NoTangent

Thunk and InplaceableThunk are unchanged.

And the old names are deprecated, not yet removed, so this is non-breaking.

Should we have tests that these things are successfully deprecated (e.g. just @test Zero() === ZeroTangent())?

I'm okay with this renaming :)

EDIT: What's happening with One?

Thanks for reviewing! I will add the deprecation tests.

I've left One for a separate PR since it was failing on julia 1.5 and 1.0.

mzgubic and others added 2 commits May 18, 2021 15:43
Co-authored-by: Nick Robinson <npr251@gmail.com>
@nickrobinson251
Copy link
Contributor

nickrobinson251 commented May 18, 2021

I've left One for a separate PR since it was failing on julia 1.5 and 1.0.

Are those the version we test on? i.e. is it passing on some versions but not others?

I ask becasue I suspect we can't use @deprecate_binding for this? And we may need to use Base.depwarn in the One() constructor e.g. struct One; One() = (Base.depwarn("`One()` is deprecated; use `true` instead", :One); new()); end

@mzgubic
Copy link
Member Author

mzgubic commented May 18, 2021

I've left One for a separate PR since it was failing on julia 1.5 and 1.0.

Are those the version we test on? i.e. is it passing on some versions but not others?

yes

I ask becasue I suspect we can't use @deprecate_binding for this? And we may need to use Base.depwarn in the One() constructor e.g. struct One; One() = (Base.depwarn("`One()` is deprecated; use `true` instead", :One); new()); end

Correct, we can't use @deprecate_binding. I am happy to do the One deprecation PR as well, just wanted to separate it from this to not delay

@mzgubic mzgubic merged commit d31fd5b into master May 19, 2021
@mzgubic mzgubic deleted the mz/rename branch May 19, 2021 08:41
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.

Renaming some things
5 participants