Handling structs without the default constructor via `Expr(:new,...` ?
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- julia
调研方向
从 CustomType MWE 开始,阅读 src/differentials/composite.jl 中的 read 构造,尤其是链接的部分。然后检查通过 FiniteDifferences 构造该类型的 CRTU 测试,并将其行为与 issue 中所描述的自定义构造函数处理进行比较。当相关的 CRTU 用例不再因这种构造函数模式而失败时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
In FiniteDifferences, this PR allowed custom constructors to be handled as part of to_vec: https://github.com/JuliaDiff/FiniteDifferences.jl/pull/181 here
However iiuc construct in CRC here doesn't handle this. In this case however, the constructor requirements are mentioned in the docstring.
However, tests in CRTU will construct the new type as part of the call to FiniteDifferences but then fail later as the constructor is not found in the call to construct.
Allowing this here, or otherwise, it would be easier if these behaviours were consistent in terms of custom types as part of the CTRU testing pipeline.
EDIT: MWE:
struct CustomType{T}
x
function CustomType(X::T) where {T}
new{T}(X)
end
end
# This misses the constructor:
CustomType{Int64}(5) # ERROR: MethodError: no method matching CustomType{Int64}(::Int64)
val = CustomType(5) # CustomType{Int64}(5)
diff = Tangent{typeof(val)}(x = 5) # Tangent{CustomType{Int64}}(x = 5,)
val + diff #ERROR: MethodError: no method matching CustomType{Int64}(::Int64)
# FiniteDifferences handles this in the vec to x:
to_vec(CustomType(5))[2]([6.0]) #CustomType{Int64}(6.0)
Defining CustomType{T}(x) where {T} = CustomType(x) allows this pass.
cc @mzgubic
- 主要语言
- Julia
- 星标
- 267
- 派生
- 66
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 9
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JuliaDiff/ChainRulesCore.jl 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 28/100
JuliaDiff/ChainRulesCore.jl#712 ·
维护者通常 1 天内回复
-
variable scope of `@thunk`可能已有人在做 @chengchingwen 于 621 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 32/100
JuliaDiff/ChainRulesCore.jl#684 ·
维护者通常 1 天内回复
-
good first issue Structural Tangent
难度 2/5 1-3 小时 新手友好度 55/100
JuliaDiff/ChainRulesCore.jl#669 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
JuliaDiff/ChainRulesCore.jl#668 · 6 条评论 ·
维护者通常 1 天内回复
-
breaking
难度 3/5 1-2 天 新手友好度 35/100
JuliaDiff/ChainRulesCore.jl#665 ·
维护者通常 1 天内回复
查看 JuliaDiff/ChainRulesCore.jl 的全部 Issue
相似的 Issue
-
release preparation spack
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
30-minutes algorithm any-language codewars dart easy elixir hackerrank hacktoberfest haskell help wanted interview-prep julia leetcode lua open-source r scala students zig
难度 2/5 1-3 小时 新手友好度 68/100
Huerte/algo-solutions-python#163 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
QuantumSavory/QuantumClifford.jl#853 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
JuliaPackaging/Yggdrasil#15441 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
JuliaSmoothOptimizers/Penelopt.jl#260 ·
维护者通常 1 天内回复