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
def test_init_errors(init_parameters): with pytest.raises(ValueError): approximator = TableApproximator(*init_parameters)
def test_encode_state(approximated_state_variables, state_shape, expected_state): state = TableApproximator.encode_state(approximated_state_variables, state_shape) assert state == expected_state
def test_encoding_states_state_values_errors(approximated_state_variables, state_shape): with pytest.raises(ValueError): TableApproximator.encode_state(approximated_state_variables, state_shape)
def test_approximate_state_variable(value, ranges, expected_state): state = TableApproximator.approximate_state_variable(value, ranges) assert state == expected_state
def test_state_shape(init_parameters, expected_possible_states): apx = TableApproximator(*init_parameters) assert apx.possible_states == expected_possible_states
def test_state_shape(init_parameters, expected_state_shape): apx = TableApproximator(*init_parameters) assert apx.state_shape == expected_state_shape