Skip to content

Commit

Permalink
Update stboutput_tests.jl - match new 2 col gains case.
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamstark authored Sep 19, 2023
1 parent ad3e61c commit 0df9660
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions test/stboutput_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ using DataFrames
using Test


@testset "basic gain lose tests" begin

d = DataFrame( weight=[200,300,200,100,100],i=[1,1,2,2,2],change=[10,2,4,5,3])
d.weighted_change = d.weight.*d.change
ogl = STBOutput.one_gain_lose( d, :i )

@test ogl."Average Change(£s)" [5.2,4.0]
@test sum( ogl."No Change") == 0
@test sum( ogl."Gain £1.01-£10" ) == sum(d.weight)

d.change = [-20,-10,0,9,88]
ogl = STBOutput.one_gain_lose( d, :i )
@test sum( ogl."No Change") == 200
@test sum( ogl."Lose £10.01+") == 200
@test sum( ogl."Gain £10.01+") == 100

end

settings = get_all_uk_settings_2023()
settings.do_marginal_rates = false
settings.poverty_line=100.0 # arbit
Expand All @@ -37,6 +19,26 @@ of = on(obs) do p
# println(tot)
end

@testset "basic gain lose tests" begin

w = [200,300,200,100,100]
d = DataFrame( weight=w./2,i=[1,1,2,2,2],change=[10,2,4,5,3],change_bhc=[5,6,7,8,9],weighted_people=w)
d.weighted_change = d.weighted_people.*d.change
ogl = STBOutput.one_gain_lose( d, :i )
println(ogl)
@test ogl."Total Transfer £m" [(5+6)*250*WEEKS_PER_YEAR/1_000_000, 24*200*WEEKS_PER_YEAR/1_000_000]
@test ogl."Average Change(£pw)" [5.2,4.0]
@test sum( ogl."No Change") == 0
@test sum( ogl."Gain £1.01-£10" ) == sum(d.weighted_people)

d.change = [-20,-10,0,9,88]
ogl = STBOutput.one_gain_lose( d, :i )
@test sum( ogl."No Change") == 200
@test sum( ogl."Lose £10.01+") == 200
@test sum( ogl."Gain £10.01+") == 100
println(ogl)
end

function avs(x::AbstractMatrix):Real
s = 0
nr,nc = size(x)
Expand Down

0 comments on commit 0df9660

Please sign in to comment.