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

Wrong method signatures for rem2pi (causing failing tests) #288

Closed
rdeits opened this issue Jan 5, 2018 · 3 comments
Closed

Wrong method signatures for rem2pi (causing failing tests) #288

rdeits opened this issue Jan 5, 2018 · 3 comments

Comments

@rdeits
Copy link

rdeits commented Jan 5, 2018

The unit tests currently fail on master with:

ERROR: LoadError: LoadError: MethodError: no method matching rem2pi(::Int64, ::Float64)
Closest candidates are:
  rem2pi(::Int64, ::RoundingMode) at math.jl:903
  rem2pi(::ForwardDiff.Dual{Tx,V,N} where N where V<:Real, ::AbstractFloat) where Tx at /home/rdeits/Downloads/packages/v0.6/ForwardDiff/src/dual.jl:104
  rem2pi(::Integer, ::ForwardDiff.Dual{Ty,V,N} where N where V<:Real) where Ty at /home/rdeits/Downloads/packages/v0.6/ForwardDiff/src/dual.jl:105
  ...
Stacktrace:
 [1] rem2pi(::ForwardDiff.Dual{DualTest.TestTag(),Int64,1}, ::Float64) at /home/rdeits/Downloads/packages/v0.6/ForwardDiff/src/dual.jl:206
 [2] macro expansion at /home/rdeits/Downloads/packages/v0.6/ForwardDiff/test/DualTest.jl:421 [inlined]
 [3] anonymous at ./<missing>:?
 [4] include_from_node1(::String) at ./loading.jl:576
 [5] include(::String) at ./sysimg.jl:14
 [6] include_from_node1(::String) at ./loading.jl:576
 [7] include(::String) at ./sysimg.jl:14
 [8] process_options(::Base.JLOptions) at ./client.jl:305
 [9] _start() at ./client.jl:371
while loading /home/rdeits/Downloads/packages/v0.6/ForwardDiff/test/DualTest.jl, in expression starting on line 29
while loading /home/rdeits/Downloads/packages/v0.6/ForwardDiff/test/runtests.jl, in expression starting on line 10

There seem to be two issues here:

  1. it looks like the unit test is trying to call rem2pi with two numeric arguments, which shouldn't work anyway
  2. rem2pi seems to be treated as a generic binary numeric operation, so its Dual methods expect both arguments to be numbers or Duals, when in fact the second argument should be a rounding mode.

Simple reproduction of (2):

julia> ForwardDiff.derivative(x -> rem2pi(x, RoundUp), 1.0)
ERROR: MethodError: no method matching rem2pi(::ForwardDiff.Dual{ForwardDiff.Tag{##3#4,Float64},Float64,1}, ::RoundingMode{:Up})
Closest candidates are:
  rem2pi(::Float64, ::RoundingMode{:Up}) at math.jl:870
  rem2pi(::Float32, ::RoundingMode) at math.jl:899
  rem2pi(::Float16, ::RoundingMode) at math.jl:900
  ...
Stacktrace:
 [1] derivative(::##3#4, ::Float64) at /home/rdeits/Downloads/packages/v0.6/ForwardDiff/src/derivative.jl:14

Perhaps rem2pi doesn't really fit the DiffRules model and should be special-cased in ForwardDiff?

@tkoolen any thoughts?

@tkoolen
Copy link

tkoolen commented Jan 5, 2018

@rdeits
Copy link
Author

rdeits commented Jan 5, 2018

Ah, gotcha. So it looks like the special case in ForwardDiff is still missing?

@jrevels jrevels mentioned this issue Jan 9, 2018
@jrevels
Copy link
Member

jrevels commented Jan 18, 2018

fixed by #290

@jrevels jrevels closed this as completed Jan 18, 2018
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

No branches or pull requests

3 participants