Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/test_ddp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,23 @@ Tests for markov/ddp.jl
@test Matrix(_ddp.Q) == _Q
end
end

# the unsorted inputs must not be mutated by construction, and
# constructing from the same arrays again must succeed (issue
# #117); fresh inputs per Q format, never passed to a constructor
# before, so that the literal baselines cannot be contaminated
for make_Q in (identity, sparse)
s_in, a_in = [1, 2, 1], [1, 1, 2]
R_in = [0.0, 2.0, 1.0]
Q_in = make_Q([1.0 0.0; 0.0 1.0; 0.5 0.5])
for _ in 1:2 # reconstruction from the same arrays must succeed
_ddp = DiscreteDP(R_in, Q_in, beta, s_in, a_in)
@test s_in == [1, 2, 1]
@test a_in == [1, 1, 2]
@test R_in == [0.0, 2.0, 1.0]
@test Matrix(Q_in) == [1.0 0.0; 0.0 1.0; 0.5 0.5]
end
end
end

@testset "num_sa_pairs and form converters" begin
Expand Down