Skip to content

Define reverse method for Composite? #253

@mzgubic

Description

@mzgubic

Should we define a reverse method for Composite?

julia> t = (1, 2, 3.0);

julia> T = typeof(t)
Tuple{Int64,Int64,Float64}

julia> reverse(t)
(3.0, 2, 1)

julia> c = Composite{T}(t)
Composite{Tuple{Int64,Int64,Float64}}((1, 2, 3.0),)

julia> reverse(c)
ERROR: MethodError: no method matching reverse(::Composite{Tuple{Int64,Int64,Float64},Tuple{Tuple{Int64,Int64,Float64}}})

It should be pointed out that reverse does not work on NamedTuples:

julia> nt = (a=1, b=2, c=3.0)
(a = 1, b = 2, c = 3.0)

julia> reverse(nt)
ERROR: MethodError: no method matching reverse(::NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Float64}})

I guess we could support it for Composites whose primal type is reverse-ible?

Metadata

Metadata

Assignees

Labels

LinearOperatorsFor issues relating to defining linear operators on AbstractDifferentialsStructural TangentRelated to the `Tangent` type for structured (composite) valuesenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions