Skip to content

Calling similar on ArrayPartition does not respect the dims argument #135

@garibarba

Description

@garibarba

Usage of similar in e.g.:
https://github.com/JuliaDiff/ForwardDiff.jl/blob/909976d719fdbd5fec91a159c6e2d808c45a770f/src/jacobian.jl#L149
is broken because it returns an ArrayPartition with the wrong number of elements.
This breaks later calls to e.g. reshape (see SciML/SciMLSensitivity.jl#404).

The returned array has the same size as the source ArrayPartition, and not the expected number of elements described by the dims argument(s).

This affects these two definitions:

# ignore dims since array partitions are vectors
Base.similar(A::ArrayPartition, dims::NTuple{N,Int}) where {N} = similar(A)

# ignore dims since array partitions are vectors
Base.similar(A::ArrayPartition, ::Type{T}, dims::NTuple{N,Int}) where {T,N} = similar(A, T)

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