def _convert_np_data(data, data_type, num_elems):
    """
        Converts a single np data into byte stream.
        """
    if data_type == 51 or data_type == 52:
        if data == '':
            return ('\x00' * num_elems).encode()
        else:
            return data.ljust(num_elems, '\x00').encode('utf-8')
    elif data_type == 32:
        data_stream = data.real.tobytes()
        data_stream += data.imag.tobytes()
        return data_stream
    else:
        return data.tobytes()
