Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Sparse ModelMatrix support #1040

Merged
merged 11 commits into from
Aug 26, 2016
7 changes: 3 additions & 4 deletions src/statsmodels/formula.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,11 @@ end
expandcols(trm::Vector)
Copy link
Member

Choose a reason for hiding this comment

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

This signature should also be updated to mention the restriction on the element type.

Create pairwise products of columns from a vector of matrices
"""
function expandcols(trm::Vector)
function expandcols{T<:ModelMatrixContainer}(trm::Vector{T})
if length(trm) == 1
asmatrix(Matrix{Float64}, convert(Array{Float64}, trm[1]))
trm[1]
else
a = convert(Array{Float64}, trm[1])
b = expandcols(trm[2 : end])
a, b = trm[1], expandcols(trm[2 : end])
Copy link
Author

@GordStephen GordStephen Aug 21, 2016

Choose a reason for hiding this comment

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

As far as I can tell, the conversions here (and just above) are redundant since elements of trm are always created by modelmat_cols, which already handles this?

Copy link
Member

Choose a reason for hiding this comment

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

Keep the assignments on two lines.

reduce(hcat, [broadcast(*, a, Compat.view(b, :, j)) for j in 1 : size(b, 2)])
end
end
Expand Down