diff --git a/machine_common_sense/serializer.py b/machine_common_sense/serializer.py index 569f46b5e..35f08acce 100644 --- a/machine_common_sense/serializer.py +++ b/machine_common_sense/serializer.py @@ -98,7 +98,7 @@ def _ext_pack(x): msgpack.packb([ x.uuid, x.color, x.dimensions, x.direction, x.distance, x.distance_in_steps, x.distance_in_world, x.held, x.mass, - x.material_list, x.position, x.rotation, x.shape, x.state_list, x.texture_color_list, x.visible + x.material_list, x.position, x.rotation, x.visible ], default=SerializerMsgPack._ext_pack, strict_types=True)) @@ -158,11 +158,11 @@ def _ext_unpack(code, data): elif code == 5: uuid, color, dimensions, direction, distance, distance_in_steps, \ distance_in_world, held, mass, material_list, position, \ - rotation, shape, state_list, texture_color_list, visible = msgpack.unpackb( + rotation, visible = msgpack.unpackb( data, ext_hook=SerializerMsgPack._ext_unpack) return ObjectMetadata(uuid, color, dimensions, direction, distance, distance_in_steps, distance_in_world, held, - mass, material_list, position, rotation, shape, state_list, texture_color_list, + mass, material_list, position, rotation, visible) elif code == 6: x = msgpack.unpackb(data, ext_hook=SerializerMsgPack._ext_unpack) @@ -260,9 +260,6 @@ def default(self, x): 'material_list': x.material_list, 'position': x.position, 'rotation': x.rotation, - 'shape': x.shape, - 'state_list': x.state_list, - 'texture_color_list': x.texture_color_list, 'visible': x.visible } elif isinstance(x, np.ndarray): @@ -282,8 +279,8 @@ def convert_object_list(raw_list): object_raw['distance'], object_raw['distance_in_steps'], object_raw['distance_in_world'], object_raw['held'], object_raw['mass'], object_raw['material_list'], - object_raw['position'], object_raw['rotation'], object_raw['shape'], object_raw['state_list'], - object_raw['texture_color_list'], object_raw['visible']) + object_raw['position'], object_raw['rotation'], + object_raw['visible']) object_list.append(obj) return object_list diff --git a/requirements.txt b/requirements.txt index 7ce7211bc..9527e72f3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,6 @@ Jinja2==2.11.3 MarkupSafe==1.1.1 matplotlib==3.3.2 msgpack==1.0.0 -numpy==1.19.4 opencv-python==4.4.0.44 packaging==20.4 pre-commit==2.7.1 diff --git a/tests/test.msgpack b/tests/test.msgpack index f1ee1653f..6dc5a1956 100644 Binary files a/tests/test.msgpack and b/tests/test.msgpack differ diff --git a/tests/test_serializer.py b/tests/test_serializer.py index 17e326859..1a8473578 100644 --- a/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -1,4 +1,3 @@ -import json import unittest import numpy as np @@ -18,9 +17,8 @@ def _helper_get_step_metadata(): def test_serialization_msgpack(self): unpacked_metadata = TestSerializer._helper_get_step_metadata() - assert abs(unpacked_metadata.reward - (-0.036000000000000004)) < 1e-04, 'Reward unexpected.' - assert abs(unpacked_metadata.rotation - 0.0) < 1e-04, 'Rotation unexpected.' - assert type(unpacked_metadata.object_list[-1].shape) == str, 'Shape type unexpected.' + assert unpacked_metadata.reward == 0.0, 'Reward unexpected.' + assert unpacked_metadata.rotation == 0.0, 'Rotation unexpected.' def test_serialization_json(self): unpacked_metadata = TestSerializer._helper_get_step_metadata() @@ -28,14 +26,12 @@ def test_serialization_json(self): serializer = mcs.SerializerJson() json_dump = serializer.serialize(unpacked_metadata) unpacked_metadata = serializer.deserialize(json_dump) - self.assertEqual(len(unpacked_metadata.depth_map_list), 1) self.assertIsInstance(unpacked_metadata.depth_map_list[0], np.ndarray) self.assertEqual(unpacked_metadata.depth_map_list[0].shape, (400, 600)) self.assertIsInstance(unpacked_metadata, mcs.StepMetadata) - self.assertAlmostEqual(unpacked_metadata.reward, -0.036000000000000004) - self.assertAlmostEqual(unpacked_metadata.rotation, 0.0, delta=1e-04) - self.assertIsInstance(unpacked_metadata.object_list[-1].shape, str) + self.assertEqual(unpacked_metadata.reward, 0.0) + self.assertEqual(unpacked_metadata.rotation, 0.0) if __name__ == '__main__':