Skip to content

Order of parameters for Partials. #161

Closed

Description

@KristofferC

The order of the parameters for the Partial type are {N,T} while for AbstractArray they are {T,N}. This leads to some confusion, for example, trying to print a partial type now gives:

julia> ForwardDiff.Dual(1, (2,3)).partials
2-element ForwardDiff.Partials{2,Int64}:
Error showing value of type ForwardDiff.Partials{2,Int64}:
------ MethodError --------------------- Stacktrace (most recent call last)

....
 [6] — print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at REPL.jl:139
 [7] — print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at REPL.jl:154
 [8] — display(::ForwardDiff.Partials{2,Int64}) at multimedia.jl:143
 [9] — display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::ForwardDiff.Partials{2,Int64}) at REPL.jl:135
 [10] — display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::ForwardDiff.Partials{2,Int64}) at REPL.jl:132
 [11] — #showarray#330(::Bool, ::Function, ::IOContext{Base.Terminals.TTYTerminal}, ::ForwardDiff.Partials{2,Int64}, ::Bool) at show.jl:1617

MethodError: no method matching isless(::Int64, ::Type{Int64})
Closest candidates are:
  isless(::Real, ::AbstractFloat) at operators.jl:41
  isless(::Real, ::ForwardDiff.Dual{N,T<:Real}) at /home/kristoffer/.julia/v0.5/ForwardDiff/src/dual.jl:130
  isless(::Real, ::Real) at operators.jl:75
  ...

This is because of ndims{T,N}(::AbstractArray{T,N}) = N in Base picking the wrong parameter. Maybe the parameters should be swapped? Implementing this function specifically for Partials, errors out in other places.

Activity

  1. added a commit that references this issue on Dec 2, 2016
    3ade4a1
  2. jrevels commented on Dec 2, 2016

    @jrevels
    Member

    Yeah, that N is a typo. Partials should just be a subtype of AbstractVector. Thanks for catching this.

  3. added a commit that references this issue on Dec 3, 2016
    aed0828
  4. added a commit that references this issue on Dec 3, 2016
    9fb6582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions