Parse the header and return it along with the input array minus the header.
    :param input_array the array to parse
    :return the codec, the length of the decoded array, the parameter and the remainder
    of the array
358037
def parse_header(input_array):
    """"""
    codec = struct.unpack(mmtf.utils.constants.NUM_DICT[4], input_array[0:4])[0]
    length = struct.unpack(mmtf.utils.constants.NUM_DICT[4], input_array[4:8])[0]
    param = struct.unpack(mmtf.utils.constants.NUM_DICT[4], input_array[8:12])[0]
    return codec,length,param,input_array[12:]
767044
def _parse_data_array(self, data_array):
        
        # decimalSeparator = data_array.encoding.decimalSeparator
        tokenSeparator = data_array.encoding.tokenSeparator
        blockSeparator = data_array.encoding.blockSeparator
        # collapseWhiteSpaces = data_array.encoding.collapseWhiteSpaces

        data_values = data_array.values
        lines = [x for x in data_values.split(blockSeparator) if x != ""]

        ret_val = []

        for row in lines:
            values = row.split(tokenSeparator)
            ret_val.append(
                [
                    float(v)
                    if " " not in v.strip()
                    else [float(vv) for vv in v.split()]
                    for v in values
                ]
            )

        # transpose into columns
        return [list(x) for x in zip(*ret_val)]
1155575
def parse_accept_header(accept):
    

    def parse_media_range(accept_item):
        """ Parse media range and subtype """

        return accept_item.split('/', 1)

    def comparator(a, b):
        """ Compare accept items a and b """

        # first compare q values
        result = -cmp(a[2], b[2])
        if result is not 0:
            # q values differ, no need to compare media types
            return result

        # parse media types and compare them (asterisks are lower in precedence)
        mtype_a, subtype_a = parse_media_range(a[0])
        mtype_b, subtype_b = parse_media_range(b[0])
        if mtype_a == '*' and subtype_a == '*':
            return 1
        if mtype_b == '*' and subtype_b == '*':
            return -1
        if subtype_a == '*':
            return 1
        if subtype_b == '*':
            return -1
        return 0

    if not accept:
        return []

    result = []
    for media_range in accept.split(","):
        parts = media_range.split(";")
        media_type = parts.pop(0).strip()
        media_params = []
        q = 1.0
        for part in parts:
            (key, value) = part.lstrip().split("=", 1)
            if key == "q":
                q = float(value)
            else:
                media_params.append((key, value))
        result.append((media_type, tuple(media_params), q))
    result.sort(comparator)
    return result
1090794
def read_input(self, input_data, data_format):
        
        if data_format not in self.input_formats:
            raise Exception("Input format {0} not available with this class. Available formats are {1}.".format(data_format, self.input_formats))
        data_converter = getattr(self, "from_" + data_format)
        self.data = data_converter(input_data)
225575
def parse(self, buffer, inlineparent = None):
        '''
        
        '''
        if len(buffer) < self.struct.size:
            return None
        try:
            return (self.struct.unpack(buffer[:self.struct.size])[0], self.struct.size)
        except struct.error as exc:
            raise BadFormatError(exc)
515937
def to_array(self):
        
        from .files import InputFile
        array = super(InputMediaVideo, self).to_array()
        # 'type' given by superclass
        # 'media' given by superclass
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = None  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if
        # 'caption' given by superclass
        # 'parse_mode' given by superclass
        if self.width is not None:
            array['width'] = int(self.width)  # type int
        if self.height is not None:
            array['height'] = int(self.height)  # type int
        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.supports_streaming is not None:
            array['supports_streaming'] = bool(self.supports_streaming)  # type bool
        return array
19557
def get_header_example(cls, header):
        
        if header.is_array:
            result = cls.get_example_for_array(header.item)
        else:
            example_method = getattr(cls, '{}_example'.format(header.type))
            result = example_method(header.properties, header.type_format)
        return {header.name: result}
985894
def parse_basic_header
      # The HEADER_SIGNATURE is defined in NIFTI::Constants and used for both reading and writing.
      header = {}
      HEADER_SIGNATURE.each do |header_item|
        name, length, type = *header_item
        header[name] = @stream.decode(length, type)
      end

      # Extract Freq, Phase & Slice Dimensions from diminfo
      if header['dim_info']
        header['freq_dim'] = dim_info_to_freq_dim(header['dim_info'])
        header['phase_dim'] = dim_info_to_phase_dim(header['dim_info'])
        header['slice_dim'] = dim_info_to_slice_dim(header['dim_info'])
      end
      header['sform_code_descr'] = XFORM_CODES[header['sform_code']]
      header['qform_code_descr'] = XFORM_CODES[header['qform_code']]

      return header
    end
566017
def decodeElem(self, bytes, index, raw=False):
        
        self._assertIndex(index)
        start = index * self.type.nbytes
        stop  = start + self.type.nbytes

        if stop > len(bytes):
            msg =  'Decoding %s[%d] requires %d bytes, '
            msg += 'but the ArrayType.decode() method received only %d bytes.'
            raise IndexError(msg % (self.type.name, index, stop, len(bytes)))

        return self.type.decode( bytes[start:stop], raw )
921114
def _convert_to_array(array_like, dtype):
        
        if isinstance(array_like, bytes):
            return np.frombuffer(array_like, dtype=dtype)
        return np.asarray(array_like, dtype=dtype)
961766
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.input_media import InputMediaPhoto
        from pytgbot.api_types.sendable.input_media import InputMediaVideo
        

        data = {}
        if isinstance(array.get('media'), InputMediaPhoto):
            data['media'] = InputMediaPhoto.from_array_list(array.get('media'), list_level=1)
        elif isinstance(array.get('media'), InputMediaVideo):
            data['media'] = InputMediaVideo.from_array_list(array.get('media'), list_level=1)
        else:
            raise TypeError('Unknown type, must be one of InputMediaPhoto, InputMediaVideo.')
        # end if
        if array.get('chat_id') is None:
            data['receiver'] = None
        elif isinstance(array.get('chat_id'), None):
            data['receiver'] = None(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), str):
            data['receiver'] = u(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), int):
            data['receiver'] = int(array.get('chat_id'))
        else:
            raise TypeError('Unknown type, must be one of None, str, int or None.')
        # end if
        if array.get('reply_to_message_id') is None:
            data['reply_id'] = None
        elif isinstance(array.get('reply_to_message_id'), DEFAULT_MESSAGE_ID):
            data['reply_id'] = DEFAULT_MESSAGE_ID(array.get('reply_to_message_id'))
        elif isinstance(array.get('reply_to_message_id'), int):
            data['reply_id'] = int(array.get('reply_to_message_id'))
        else:
            raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int or None.')
        # end if
        data['disable_notification'] = bool(array.get('disable_notification')) if array.get('disable_notification') is not None else None
        return MediaGroupMessage(**data)
496917
def parse_array(raw_array):
    """"""
    array_strip_brackets = raw_array.replace('{', '').replace('}', '')
    array_strip_spaces = array_strip_brackets.replace('"', '').replace(' ', '')
    return array_strip_spaces.split(',')
58037
def decode(C):
    
    C = array(C)

    flatten = False
    if len(C.shape) == 1:
        flatten = True
        C = C.reshape(1, -1)

    if C.shape[1] != msg_size:
        raise ValueError('Data must be shaped as (7, ) or (-1, 7)')

    if 1 in dot(H, C.T).T % 2:
        raise ValueError('Incorrect code given as input.')

    B = C[:, data_bits]

    if flatten:
        B = B.flatten()

    return B
832453
def process_header(raw)
      # this util gives us arrays of values. We are only set up to handle one header value.
      WEBrick::HTTPUtils.parse_header(raw.strip).map.inject({}) do |h,(k,v)|
        h[k]=v.first; h
      end
    end
597177
def header(self, array):
        

        self._check_row_size(array)
        self._header = map(str, array)
1195252
def parse_subprotocol_item(
    header: str, pos: int, header_name: str
) -> Tuple[Subprotocol, int]:
    
    item, pos = parse_token(header, pos, header_name)
    return cast(Subprotocol, item), pos
687192
int decode( byte[] buffer, int bufferIndex ) {
        int start = headerStart = bufferIndex;

        bufferIndex += readHeaderWireFormat( buffer, bufferIndex );
        bufferIndex += readAndXWireFormat( buffer, bufferIndex );

        length = bufferIndex - start;
        return length;
    }