Skip to content

Commit

Permalink
some tests for bymap utils
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed May 28, 2020
1 parent ffc45ed commit 39c3229
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/bymap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ function arggetter(i,a::Union{SomeKindOfParticles, NamedTuple})
vecindex(a,i)
end

function arggetter(i,a)
a
end
arggetter(i,a) = a


"""
@bymap f(p, args...)
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ Random.seed!(0)
g2(a,nt::NamedTuple) = a + nt.x^2 + nt.y^2
@test g2(p_3, (x=p_1, y=p_2)) == p_3 + p_1^2 + p_2^2

@test_throws ErrorException bymap(x->ones(3,3,3,3), p)
@test_throws ErrorException bypmap(x->ones(3,3,3,3), p)
@test MonteCarloMeasurements.arggetter(1,1) == 1

@test MonteCarloMeasurements.particletype(p) == Particles{Float64,DEFAULT_NUM_PARTICLES}
@test MonteCarloMeasurements.particletype(Particles{Float64,DEFAULT_NUM_PARTICLES}) == Particles{Float64,DEFAULT_NUM_PARTICLES}
@test MonteCarloMeasurements.particletype([p,p]) == Particles{Float64,DEFAULT_NUM_PARTICLES}
@test MonteCarloMeasurements.nparticles(p) == DEFAULT_NUM_PARTICLES




@testset "@prob" begin
Expand Down

0 comments on commit 39c3229

Please sign in to comment.