Skip to content

Commit c94ce7c

Browse files
authored
Merge pull request #79 from ACEsuit/co/lenbasis
Introduce `basis_size`
2 parents 9290dcb + c097b5f commit c94ce7c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/assemble.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ using ParallelDataTransfer
33
using ProgressMeter
44
using SharedArrays
55

6+
"""
7+
basis_size(model)
8+
9+
Return the length of the basis, assuming that `model` is a linear model, or
10+
when interpreted as a linear model. The returned integer must match the
11+
size of the feature matrix that will be assembled for the given model.
12+
13+
It defaults to `Base.length` but can be overloaded if needed.
14+
"""
15+
basis_size(model) = Base.length(model)
16+
617
struct DataPacket{T <: AbstractData}
718
rows::UnitRange
819
data::T
@@ -23,8 +34,8 @@ function assemble(data::AbstractVector{<:AbstractData}, basis)
2334
packets = DataPacket.(rows, data)
2435
sort!(packets, by = length, rev = true)
2536
(nprocs() > 1) && sendto(workers(), basis = basis)
26-
@info " - Creating feature matrix with size ($(rows[end][end]), $(length(basis)))."
27-
A = SharedArray(zeros(rows[end][end], length(basis)))
37+
@info " - Creating feature matrix with size ($(rows[end][end]), $(basis_size(basis)))."
38+
A = SharedArray(zeros(rows[end][end], basis_size(basis)))
2839
Y = SharedArray(zeros(size(A, 1)))
2940
@info " - Beginning assembly with processor count: $(nprocs())."
3041
@showprogress pmap(packets) do p

0 commit comments

Comments
 (0)