From 9029e522e0ff60420ab7febd675e8bb6c80ab8a2 Mon Sep 17 00:00:00 2001 From: Vadim Liventsev Date: Mon, 25 Mar 2024 10:51:38 +0100 Subject: [PATCH] Fixed action handling in agents --- programlib/agent.py | 7 +++++-- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/programlib/agent.py b/programlib/agent.py index 68d3668..a9dbca1 100644 --- a/programlib/agent.py +++ b/programlib/agent.py @@ -9,9 +9,12 @@ def decode_action(action): except SyntaxError: x = np.array(list(map(eval, action.split(r'[\p\s]+')))) - return x.reshape(-1) + x = x.reshape(-1) + if x.size == 1: + x = x[0] + return x except SyntaxError as e: - raise RuntimeError(f'Action {action} not recognized. Please use numbers only') from e + raise RuntimeError(f'{action}\nis not a valid action') from e def encode_obs(obs): try: diff --git a/pyproject.toml b/pyproject.toml index 24b0db6..97fcdb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "programlib" -version = "10.3.1" +version = "10.4.0" description = "Programs as Objects" authors = ["Vadim Liventsev "] license = "MIT"