_ClassDataPoint.py
Go to the documentation of this file.
00001 """autogenerated by genpy from ml_classifiers/ClassDataPoint.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 
00008 class ClassDataPoint(genpy.Message):
00009   _md5sum = "46bea2d2ef979a71ef0bfa470e5978ff"
00010   _type = "ml_classifiers/ClassDataPoint"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """string target_class
00013 float64[] point
00014 
00015 """
00016   __slots__ = ['target_class','point']
00017   _slot_types = ['string','float64[]']
00018 
00019   def __init__(self, *args, **kwds):
00020     """
00021     Constructor. Any message fields that are implicitly/explicitly
00022     set to None will be assigned a default value. The recommend
00023     use is keyword arguments as this is more robust to future message
00024     changes.  You cannot mix in-order arguments and keyword arguments.
00025 
00026     The available fields are:
00027        target_class,point
00028 
00029     :param args: complete set of field values, in .msg order
00030     :param kwds: use keyword arguments corresponding to message field names
00031     to set specific fields.
00032     """
00033     if args or kwds:
00034       super(ClassDataPoint, self).__init__(*args, **kwds)
00035       #message fields cannot be None, assign default values for those that are
00036       if self.target_class is None:
00037         self.target_class = ''
00038       if self.point is None:
00039         self.point = []
00040     else:
00041       self.target_class = ''
00042       self.point = []
00043 
00044   def _get_types(self):
00045     """
00046     internal API method
00047     """
00048     return self._slot_types
00049 
00050   def serialize(self, buff):
00051     """
00052     serialize message into buffer
00053     :param buff: buffer, ``StringIO``
00054     """
00055     try:
00056       _x = self.target_class
00057       length = len(_x)
00058       if python3 or type(_x) == unicode:
00059         _x = _x.encode('utf-8')
00060         length = len(_x)
00061       buff.write(struct.pack('<I%ss'%length, length, _x))
00062       length = len(self.point)
00063       buff.write(_struct_I.pack(length))
00064       pattern = '<%sd'%length
00065       buff.write(struct.pack(pattern, *self.point))
00066     except struct.error as se: self._check_types(se)
00067     except TypeError as te: self._check_types(te)
00068 
00069   def deserialize(self, str):
00070     """
00071     unpack serialized message in str into this message instance
00072     :param str: byte array of serialized message, ``str``
00073     """
00074     try:
00075       end = 0
00076       start = end
00077       end += 4
00078       (length,) = _struct_I.unpack(str[start:end])
00079       start = end
00080       end += length
00081       if python3:
00082         self.target_class = str[start:end].decode('utf-8')
00083       else:
00084         self.target_class = str[start:end]
00085       start = end
00086       end += 4
00087       (length,) = _struct_I.unpack(str[start:end])
00088       pattern = '<%sd'%length
00089       start = end
00090       end += struct.calcsize(pattern)
00091       self.point = struct.unpack(pattern, str[start:end])
00092       return self
00093     except struct.error as e:
00094       raise genpy.DeserializationError(e) #most likely buffer underfill
00095 
00096 
00097   def serialize_numpy(self, buff, numpy):
00098     """
00099     serialize message with numpy array types into buffer
00100     :param buff: buffer, ``StringIO``
00101     :param numpy: numpy python module
00102     """
00103     try:
00104       _x = self.target_class
00105       length = len(_x)
00106       if python3 or type(_x) == unicode:
00107         _x = _x.encode('utf-8')
00108         length = len(_x)
00109       buff.write(struct.pack('<I%ss'%length, length, _x))
00110       length = len(self.point)
00111       buff.write(_struct_I.pack(length))
00112       pattern = '<%sd'%length
00113       buff.write(self.point.tostring())
00114     except struct.error as se: self._check_types(se)
00115     except TypeError as te: self._check_types(te)
00116 
00117   def deserialize_numpy(self, str, numpy):
00118     """
00119     unpack serialized message in str into this message instance using numpy for array types
00120     :param str: byte array of serialized message, ``str``
00121     :param numpy: numpy python module
00122     """
00123     try:
00124       end = 0
00125       start = end
00126       end += 4
00127       (length,) = _struct_I.unpack(str[start:end])
00128       start = end
00129       end += length
00130       if python3:
00131         self.target_class = str[start:end].decode('utf-8')
00132       else:
00133         self.target_class = str[start:end]
00134       start = end
00135       end += 4
00136       (length,) = _struct_I.unpack(str[start:end])
00137       pattern = '<%sd'%length
00138       start = end
00139       end += struct.calcsize(pattern)
00140       self.point = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
00141       return self
00142     except struct.error as e:
00143       raise genpy.DeserializationError(e) #most likely buffer underfill
00144 
00145 _struct_I = genpy.struct_I


ml_classifiers
Author(s): Scott Niekum
autogenerated on Fri Jan 3 2014 11:30:23