Skip to content

Fix frule for static array constructor that converts eltype - #275

Merged
staticfloat merged 2 commits into
mainfrom
ox/st_con
Mar 5, 2024
Merged

Fix frule for static array constructor that converts eltype#275
staticfloat merged 2 commits into
mainfrom
ox/st_con

Conversation

@oxinabox

Copy link
Copy Markdown
Member

Previously for the convertable case this errored with

 DimensionMismatch: No precise constructor for SVector{3, Float64} found. Length of input was 1

This does make use of the general assumption of ChainRulesCore that Number's are their own tangent type.
But I think that is fine, that assumption exists in a whole bunch of places and if you violate it you should expect suffering.

Comment threadsrc/extra_rules.jl
Comment threadtest/extra_rules.jl
@test ẏ == @SVector [0.0, 0.0, 0.0]
end

@testset "convertable type" begin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this case different than the first?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first element of x is an Int rather than an Float64

Comment threadtest/extra_rules.jl Outdated
@oxinabox

Copy link
Copy Markdown
MemberAuthor

cool and I see you have pushed this to the for_cedar branch also

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@oxinabox@staticfloat