GLM.jl icon indicating copy to clipboard operation
GLM.jl copied to clipboard

convert all eltypes of GlmResp args to the eltype of the first

Open dsweber2 opened this issue 4 years ago • 2 comments

min example: GLM.GlmResp(randn(10), Binomial(), LogitLink(), randn(Float32, 10), randn(10)) Gets stuck in a loop because float won't convert Float64 and Float32 to the same type. I just turned the first one into a float, and then made the rest match that type of float explicitly.

dsweber2 avatar Apr 14 '20 17:04 dsweber2

digging a bit further, it seems the problem I was trying to address with this was actually caused in Lasso.jl, which was inconsistent about handing Float32 and Float64 to GLM.jl. I think this pull is still worth changing, but there are several changes elsewhere that are also needed if the input is somewhat inconsistent about the type of float involved.

dsweber2 avatar Apr 14 '20 20:04 dsweber2

Thanks. Though note that float only makes a copy when necessary, contrary to what would happen with this PR. Can you change it to use convert instead? Also better use promote_type to choose the appropriate destination type.

nalimilan avatar May 07 '20 16:05 nalimilan