Esempio n. 1
0
def test_approximate_state(n_state_vars, state_vars_ranges, state_vars,
                           expected_state):
    apx = TableApproximator(n_state_vars, state_vars_ranges)
    state = apx.approximate_state(state_vars)
    assert state == expected_state
Esempio n. 2
0
def test_init_errors(init_parameters):
    with pytest.raises(ValueError):
        approximator = TableApproximator(*init_parameters)
Esempio n. 3
0
def test_encode_state(approximated_state_variables, state_shape,
                      expected_state):
    state = TableApproximator.encode_state(approximated_state_variables,
                                           state_shape)
    assert state == expected_state
Esempio n. 4
0
def test_encoding_states_state_values_errors(approximated_state_variables,
                                             state_shape):
    with pytest.raises(ValueError):
        TableApproximator.encode_state(approximated_state_variables,
                                       state_shape)
Esempio n. 5
0
def test_approximate_state_variable(value, ranges, expected_state):
    state = TableApproximator.approximate_state_variable(value, ranges)
    assert state == expected_state
Esempio n. 6
0
def test_state_shape(init_parameters, expected_possible_states):
    apx = TableApproximator(*init_parameters)
    assert apx.possible_states == expected_possible_states
Esempio n. 7
0
def test_state_shape(init_parameters, expected_state_shape):
    apx = TableApproximator(*init_parameters)
    assert apx.state_shape == expected_state_shape