I'm trying to print out some values in Gymnasium (previously OpenAI Gym), such as:
import gymnasium as gym
env = gym.make("LunarLander-v2", render_mode="human")
observation, info = env.reset()
print(f'env.observation_space: {env.observation_space}')
print(f'obs: {observation}')
The output looks like:
env.observation_space: Box([-90. -90. -5. -5. -3.1415927 -5.
-0. -0. ], [90. 90. 5. 5. 3.1415927 5.
1. 1. ], (8,), float32)
obs: [-0.00316305 1.3999956 -0.3203935 -0.48554128 0.00367194 0.072574
0. 0. ]
Is there any way to set options such as set_option('display.max_columns', 500) or
set_option('display.width', 1000) like Pandas?
- The tag should be Gymnasium but there's only openai-gym right now, so I'm using it.
- I'm not sure if StackOverflow is the right place to ask this question, but there are many questions like this and helpful answers. Please let me know if there's any advice.
EDIT) Summing up the comment and answers:
- use
np.set_printoptions(linewidth=1000)sinceBox2Dhas a np.array representation. (np.set_printoptionshas more options so please check them out) - Use pprint:
pp = pprint.PrettyPrinter(width=500, compact=True); pp.pprint(...) - Use
np.array2stringif it's np.array. (observation is np.array so this works, but Gymnasium spaces such asBoxitself are not numpy array so this doesn't work. Though its "representation" seems to be a numpy array so the solution 1 works.)