-
Notifications
You must be signed in to change notification settings - Fork 5
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
More problems regarding round
#164
Comments
This is the same problem as mentioned in #152 (comment) |
I'll take a look! Could you check whether |
The problem in #152 is now part of our test suite, so I'd be surprised if it doesn't work: SparseConnectivityTracer.jl/test/test_gradient.jl Lines 222 to 223 in 199899d
|
If you want an explicit conversation for some reason, EDIT: Should work with |
Thanks. I'm running the unreleased |
The problem seems to be that |
Why is the instance of |
If this was possible, it would indeed simplify things a lot. Unfortunately, Julia's type system doesn't allow it. SparseConnectivityTracer.jl/src/tracers.jl Lines 103 to 105 in 199899d
In this specific instance, we could (and I guess should?) indeed return an More generally speaking, for things like This is somewhat of a design dilemma for us: do we (a) make the code work on most user-provided functions at the cost of invalidating some code or do we (b) throw a lot of errors and require users to rewrite their code such that it is compatible with SCT? For now, we aim for (a). julia> using ForwardDiff
julia> ForwardDiff.derivative(x -> convert(Int, x), 1)
ERROR: InexactError: Int(Int64, Dual{ForwardDiff.Tag{var"#3#4", Int64}}(1,1))
Stacktrace:
[1] Int64
@ ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:364 [inlined]
[2] convert
@ ./number.jl:7 [inlined]
[3] #3
@ ./REPL[3]:1 [inlined]
[4] derivative(f::var"#3#4", x::Int64)
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/derivative.jl:14
[5] top-level scope
@ REPL[3]:1 Whether we stick with approach (a) and the invalidations or whether we move to approach (b) is something we should revisit before we tag a |
That's not true for |
Let's discuss this in #167! |
To come back to the initial issue @SouthEndMusic: |
Wait why? We can return an int in every case. And what you suggest sounds type unstable. |
Once again, let's discuss this in #167, it deserves its own issue outside of one on ForwardDiff's approach I linked above is not type unstable: an |
I did a quick test with the current main and I still have a problem with the function
round
where I want the return type to be an integer (and thus not depend smoothly on the input).f(x) = Int(round(x))
doesn't work:Is that something you plan to support? Or should I resolve this in a different way? Still in the context of
DataInterpolations
by the way.The text was updated successfully, but these errors were encountered: