From 13d3653c7a40e2b97bc694f3602a715b2ae6a85f Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 24 May 2024 17:56:31 +0200 Subject: [PATCH] Fix test_dict_info_to_list test on Windows --- .../wrappers/vector/test_dict_info_to_list.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/wrappers/vector/test_dict_info_to_list.py b/tests/wrappers/vector/test_dict_info_to_list.py index 9e61f29b9..f07c97005 100644 --- a/tests/wrappers/vector/test_dict_info_to_list.py +++ b/tests/wrappers/vector/test_dict_info_to_list.py @@ -60,9 +60,13 @@ def test_update_info(): "_e": np.array([True]), } _, list_info = env.reset(options=vector_infos) + + # The return dtype of np.array([0]) is platform dependent + np_array_int_default_dtype = np.array([0]).dtype.type + expected_list_info = [ { - "a": np.int64(0), + "a": np_array_int_default_dtype(0), "b": np.float64(0.0), "c": None, "d": np.zeros((2,)), @@ -90,21 +94,21 @@ def test_update_info(): _, list_info = env.reset(options=vector_infos) expected_list_info = [ { - "a": np.int64(0), + "a": np_array_int_default_dtype(0), "b": np.float64(0.0), "c": None, "d": np.zeros((2,)), "e": Discrete(1), }, { - "a": np.int64(1), + "a": np_array_int_default_dtype(1), "b": np.float64(1.0), "c": None, "d": np.zeros((2,)), "e": Discrete(2), }, { - "a": np.int64(2), + "a": np_array_int_default_dtype(2), "b": np.float64(2.0), "c": None, "d": np.zeros((2,)), @@ -134,7 +138,7 @@ def test_update_info(): } _, list_info = env.reset(options=vector_infos) expected_list_info = [ - {"a": np.int64(1), "b": np.float64(1.0)}, + {"a": np_array_int_default_dtype(1), "b": np.float64(1.0)}, {"c": None, "d": np.zeros((2,))}, {"e": Discrete(3)}, ] @@ -156,8 +160,11 @@ def test_update_info(): } _, list_info = env.reset(options=vector_infos) expected_list_info = [ - {"episode": {"a": np.int64(1), "b": np.float64(1.0)}}, - {"episode": {"a": np.int64(2), "b": np.float64(2.0)}, "a": np.int64(1)}, - {"a": np.int64(2)}, + {"episode": {"a": np_array_int_default_dtype(1), "b": np.float64(1.0)}}, + { + "episode": {"a": np_array_int_default_dtype(2), "b": np.float64(2.0)}, + "a": np_array_int_default_dtype(1), + }, + {"a": np_array_int_default_dtype(2)}, ] assert data_equivalence(list_info, expected_list_info)