Allows reconstructing indefinite length values

        :return:
            A tuple of integers
427126
def _as_chunk(self):
        

        extra_bits = int_from_bytes(self.contents[0:1])
        byte_len = len(self.contents[1:])
        bit_string = '' if byte_len == 0 else '{0:b}'.format(int_from_bytes(self.contents[1:]))
        bit_len = len(bit_string)

        # Left-pad the bit string to a byte multiple to ensure we didn't
        # lose any zero bits on the left
        mod_bit_len = bit_len % 8
        if mod_bit_len != 0:
            bit_string = ('0' * (8 - mod_bit_len)) + bit_string
            bit_len = len(bit_string)

        if bit_len // 8 < byte_len:
            missing_bytes = byte_len - (bit_len // 8)
            bit_string = ('0' * (8 * missing_bytes)) + bit_string

        # Trim off the extra bits on the right used to fill the last byte
        if extra_bits > 0:
            bit_string = bit_string[0:0 - extra_bits]

        return tuple(map(int, tuple(bit_string)))
1186519
def encoded_length(self, num_bytes=16):
        
        factor = math.log(256) / math.log(self._alpha_len)
        return int(math.ceil(factor * num_bytes))
266464
def length_by_id(self):
        """"""
        hashmap = dict((seq.id, len(seq)) for seq in self)
        tmp = hashmap.copy()
        hashmap.update(tmp)
        return hashmap
150158
def _extract_lengths(ll):
    """"""
    results = set()
    if ll is None:
        return []
    for val in ll.split(','):
        m = _NUM_RE.match(val)
        if m:
            results.add(int(val))
        else:
            m = _RANGE_RE.match(val)
            if m is None:
                raise Exception("Unrecognized length specification %s" % ll)
            min = int(m.group('min'))
            max = int(m.group('max'))
            for ii in range(min, max + 1):
                results.add(ii)
    return sorted(list(results))
921650
def padding_to_length(padding):
  
  non_padding = 1.0 - padding
  return tf.to_int32(tf.reduce_sum(non_padding, axis=-1))
826074
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, str):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
1318144
def get_value_length(byte):
    
    length_value = byte & length_type_mask
    return LengthTypes.to_ints.get(length_value, byte & length_mask)
754423
def parse_length_dist(self, f):
        
        parsed_data = dict()
        firstline = True
        for l in f['f']:
            if firstline:    #skip first line
                firstline = False
                continue
            s = l.split("\t")
            if len(s) > 1:
                k = float(s[0].strip())
                v = float(s[1].strip())
                parsed_data[k] = v

        return parsed_data
700132
def to_tuple(self, iterable, surround="()", joiner=", "):
    """"""
    return "{0}{1}{2}".format(surround[0], joiner.join(iterable), surround[1])
1234442
def toints(self):
        
        def grouper(iterable, n, fillvalue=None):
            "Collect data into fixed-length chunks or blocks"
            # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
            return zip_longest(*[iter(iterable)] * n, fillvalue=fillvalue)
        return [int(''.join(map(str, group)), 2) for group in grouper(self._data, 8, 0)]
88160
def _maxlength(X):
    
    return np.fromiter((map(lambda x: len(x), X)), dtype=int).max()
858133
def from_cstr_to_pystr(data, length):
    
    if PY3:
        res = []
        for i in range(length.value):
            try:
                res.append(str(data[i].decode('ascii')))
            except UnicodeDecodeError:
                res.append(str(data[i].decode('utf-8')))
    else:
        res = []
        for i in range(length.value):
            try:
                res.append(str(data[i].decode('ascii')))
            except UnicodeDecodeError:
                # pylint: disable=undefined-variable
                res.append(unicode(data[i].decode('utf-8')))
    return res
1311925
private int getLength()
    {
        if (m_length_ >= 0) {
            return m_length_;
        }
        int length = m_key_.length;
        for (int index = 0; index < length; index ++) {
            if (m_key_[index] == 0) {
                length = index;
                break;
            }
        }
        m_length_ = length;
        return m_length_;
    }
1310048
def from_int(cls, integer):
        
        bin_string = bin(integer)

        return cls(
            text=len(bin_string) >= 1 and bin_string[-1] == "1",
            comment=len(bin_string) >= 2 and bin_string[-2] == "1",
            user=len(bin_string) >= 3 and bin_string[-3] == "1",
            restricted=len(bin_string) >= 4 and bin_string[-4] == "1"
        )
838816
def to_python_index(self, length, check_bounds=True, circular=False):
        
        if not self.is_unitless:
            raise ValueError("Index cannot have units: {0!r}".format(self))

        ret = int(self.value)
        if ret != self.value:
            raise ValueError("Index must be an integer: {0!r}".format(ret))

        if ret == 0:
            raise ValueError("Index cannot be zero")

        if check_bounds and not circular and abs(ret) > length:
            raise ValueError("Index {0!r} out of bounds for length {1}".format(ret, length))

        if ret > 0:
            ret -= 1

        if circular:
            ret = ret % length

        return ret
684366
def get_tuple(self):
        """"""
        objType, objInstance = self.value

        if isinstance(objType, int):
            pass
        elif isinstance(objType, long):
            objType = int(objType)
        elif isinstance(objType, basestring):
            # turn it back into an integer
            objType = self.objectTypeClass()[objType]
        else:
            raise TypeError("invalid datatype for objType")

        # pack the components together
        return (objType, objInstance)
11438
def str2tuple(str_in):
    '''
    
    '''
    tuple_out = safe_eval(str_in)
    if not isinstance(tuple_out, tuple):
        tuple_out = None
    return tuple_out