37 from cStringIO
import StringIO
39 from io
import StringIO
48 print(
"cannot import numpy, test is disabled")
52 from test_rospy.msg
import Floats
60 vals = [1.0, 2.1, 3.2, 4.3, 5.4, 6.5]
62 f = Floats(numpy.array([1.0, 2.1, 3.2, 4.3, 5.4, 6.5], dtype=numpy.float32))
67 self.assert_(type(f2.data) == list)
68 f2.deserialize(b.getvalue())
69 for x, y
in zip(f2.data, vals):
70 self.assertAlmostEquals(x, y, 2)
72 from rospy.numpy_msg
import numpy_msg
73 f3 = numpy_msg(Floats)()
76 self.assert_(isinstance(f3.data, numpy.ndarray), type(f3.data))
77 f3.deserialize(b.getvalue())
78 self.assert_(isinstance(f3.data, numpy.ndarray), type(f3.data))
79 v = numpy.equal(f3.data, numpy.array([1.0, 2.1, 3.2, 4.3, 5.4, 6.5], dtype=numpy.float32))
83 from rospy.numpy_msg
import numpy_msg
84 self.assert_(isinstance(numpy_msg(Floats)(), numpy_msg(Floats)))
86 FloatsNP = numpy_msg(Floats)
87 FloatsNP2 = numpy_msg(Floats)
89 self.assert_(FloatsNP
is FloatsNP2)
def test_class_identity(self)