Skip to content

Commit

Permalink
zero r/c check in weighting
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamstark committed Aug 22, 2024
1 parent d49a17c commit 18e1005
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Weighting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,30 @@ function generate_weights(
initialise_target_dataframe :: Function = initialise_target_dataframe_scotland_2022,
make_target_row! :: Function = make_target_row_scotland_2022! ) :: Vector

function check_data( d, nrows, ncols )
zrows = Int[]
for r in 1:nrows
if sum( d[r,:] ) == 0
push!(zrows,r)
end
end
zcols = Int[]
@assert length(zrows) == 0 "data has all-zero rows for rows $(zrows)"
for c in 1:ncols
if sum( d[:,c] ) == 0
push!(zcols,c)
end
end
@assert length(zcols) == 0 "data has all-zero cols $(zcols)"
end

data :: Matrix = make_target_dataset(
nhhlds,
initialise_target_dataframe,
make_target_row! )
# println( data )
nrows = size( data )[1]
ncols = size( data )[2]
nrows, ncols = size( data )
check_data( data, nrows, ncols )
## FIXME parameterise this
initial_weights = ones(nhhlds)*household_total/nhhlds
println( "initial_weights $(initial_weights[1])")
Expand Down

0 comments on commit 18e1005

Please sign in to comment.