Skip to content

Commit

Permalink
Fixed action handling in agents
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim0x60 committed Mar 25, 2024
1 parent d620c9f commit 9029e52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions programlib/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "programlib"
version = "10.3.1"
version = "10.4.0"
description = "Programs as Objects"
authors = ["Vadim Liventsev <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 9029e52

Please sign in to comment.