From 4485db9dded42ba37fcf5801bc79732e9a0517b1 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 4 Apr 2019 09:32:17 -0700 Subject: [PATCH] fix echo of numpy.number values (#37) Signed-off-by: Dirk Thomas --- rosidl_runtime_py/rosidl_runtime_py/convert.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rosidl_runtime_py/rosidl_runtime_py/convert.py b/rosidl_runtime_py/rosidl_runtime_py/convert.py index 573d4caf..663384db 100644 --- a/rosidl_runtime_py/rosidl_runtime_py/convert.py +++ b/rosidl_runtime_py/rosidl_runtime_py/convert.py @@ -150,9 +150,9 @@ def _convert_value(value, truncate_length=None): # Don't truncate keys because that could result in key collisions and data loss new_value[_convert_value(k)] = _convert_value(v, truncate_length=truncate_length) value = new_value - elif ( - not any(isinstance(value, t) for t in (bool, float, int, numpy.number)) - ): + elif isinstance(value, numpy.number): + value = value.item() + elif not any(isinstance(value, t) for t in (bool, float, int)): # Assuming value is a message since it is neither a collection nor a primitive type value = message_to_ordereddict(value, truncate_length=truncate_length) return value