Commit b2101b2f by Steven Cordwell

### [tests] Change example module tests

Add to and improve the quality of the tests for the example module. This
commit also fixes a small bug in the example module when dealing with
sparse masks to the example.rand function.
parent 81b4d6d5
 ... @@ -299,7 +299,12 @@ def rand(S, A, is_sparse=False, mask=None): ... @@ -299,7 +299,12 @@ def rand(S, A, is_sparse=False, mask=None): if n == 0: if n == 0: m[randint(0, S)] = 1 m[randint(0, S)] = 1 n = 1 n = 1 cols = where(m)[0] # m[s, :] # find the columns of the vector that have non-zero elements nz = m.nonzero() if len(nz) == 1: cols = nz[0] else: cols = nz[1] vals = random(n) vals = random(n) vals = vals / vals.sum() vals = vals / vals.sum() reward = 2*random(n) - ones(n) reward = 2*random(n) - ones(n) ... @@ -330,7 +335,6 @@ def rand(S, A, is_sparse=False, mask=None): ... @@ -330,7 +335,6 @@ def rand(S, A, is_sparse=False, mask=None): # Make sure that there is atleast one transition in each state # Make sure that there is atleast one transition in each state if m.sum() == 0: if m.sum() == 0: m[randint(0, S)] = 1 m[randint(0, S)] = 1 n = 1 P[a][s] = m * random(S) P[a][s] = m * random(S) P[a][s] = P[a][s] / P[a][s].sum() P[a][s] = P[a][s] / P[a][s].sum() R[a][s] = (m * (2*random(S) - ones(S, dtype=int))) R[a][s] = (m * (2*random(S) - ones(S, dtype=int))) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment