LearnAPI.clone calls the advertised keyword constructor positionally
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- julia
- Lĩnh vực
- api, machine-learning
Hướng nghiên cứu
Bắt đầu tại src/clone.jl, khoảng dòng 26, và so sánh lời gọi constructor với hợp đồng của keyword constructor được mô tả trong issue. Chạy trình tái hiện DemoLearner để xác minh lỗi, sau đó xác nhận rằng clone hoạt động với constructor chỉ nhận keyword được tài liệu hóa và cân nhắc tác động đối với khả năng tương thích của các positional constructor hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
While working on a downstream package (OnlineML.jl), I noticed a discrepancy between the constructor trait documentation and the actual implementation of LearnAPI.clone.
The constructor trait documentation requires a keyword constructor and demonstrates reconstruction with:
LearnAPI.constructor(learner)(; named_properties...)
However, LearnAPI.clone currently collects the learner properties and passes them as positional arguments by splatting a NamedTuple without a semicolon:
LearnAPI.constructor(learner)(NamedTuple{names}(new_values)...)
Minimal reproducer
using LearnAPI
Base.@kwdef struct DemoLearner
rate::Float64 = 0.1
end
LearnAPI.constructor(::DemoLearner) = DemoLearner
LearnAPI.clone(DemoLearner(); rate=0.2)
Expected Behavior
DemoLearner(0.2) should be returned through the documented keyword-constructor contract (e.g., if clone splatted with a semicolon: ; NamedTuple{names}(new_values)...).
Actual Behavior
clone calls DemoLearner(0.2) positionally. A learner that intentionally provides only the documented keyword constructor (like the one generated by Base.@kwdef without a custom positional fallback) raises a MethodError.
Additional Context
Currently, downstream learners with properties must provide an additional positional constructor solely for compatibility with LearnAPI.clone.
Fixing this by changing clone to splat the named tuple as keywords (;) would align the code with the documentation. However, please note that changing clone upstream may affect existing learners that have already implemented (or only implemented) a positional constructor to work around this, so an upstream compatibility transition/deprecation phase might be necessary.
Affected code
Possible change
return LearnAPI.constructor(learner)(; NamedTuple{names}(new_values)...)
PS : this issue have been filled with AI assistance
- Ngôn ngữ chính
- Julia
- Star
- 45
- Fork
- 2
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaAI/LearnAPI.jl
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
JuliaAI/LearnAPI.jl#19 ·
Tất cả issue của JuliaAI/LearnAPI.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
SciML/ModelingToolkit.jl#5255 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
QuantEcon/QuantEcon.jl#412 ·
-
docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SciML/ModelingToolkitStandardLibrary.jl#521 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CliMA/Oceananigans.jl#6144 ·
Maintainer thường phản hồi trong vòng 1 ngày