Series from binary string arguments.
192677
def frombits(cls, bits):
        """"""
        return cls.frombitsets(map(cls.BitSet.frombits, bits))
883500
def _to_args(x):
    """"""
    if not isinstance(x, (list, tuple, np.ndarray)):
        x = [x]
    return x
1282775
def binary_op(data, op, other, blen=None, storage=None, create='array',
              **kwargs):
    """"""

    # normalise scalars
    if hasattr(other, 'shape') and len(other.shape) == 0:
        other = other[()]

    if np.isscalar(other):
        def f(block):
            return op(block, other)
        return map_blocks(data, f, blen=blen, storage=storage, create=create, **kwargs)

    elif len(data) == len(other):
        def f(a, b):
            return op(a, b)
        return map_blocks((data, other), f, blen=blen, storage=storage, create=create,
                          **kwargs)

    else:
        raise NotImplementedError('argument type not supported')
1068260
def gray2int(graystr):
    """"""
    num = bin2int(graystr)
    num ^= (num >> 8)
    num ^= (num >> 4)
    num ^= (num >> 2)
    num ^= (num >> 1)
    return num
672979
def cast(s):
    '''
    
    '''
    if not isinstance(s, basestring):
        raise TypeError("argument must be a string")
    for test in [int, float, str]:
        try:
            return test(s)
        except ValueError:
            continue
    return str(s)
385725
def str2int(num, radix=10, alphabet=BASE85):
    """"""
    return NumConv(radix, alphabet).str2int(num)
246695
function assembleOtherSeries(series) {
    return zrUtil.map(series, function (series) {
        var data = series.getRawData();
        var lines = [series.name];
        var vals = [];
        data.each(data.dimensions, function () {
            var argLen = arguments.length;
            var dataIndex = arguments[argLen - 1];
            var name = data.getName(dataIndex);
            for (var i = 0; i < argLen - 1; i++) {
                vals[i] = arguments[i];
            }
            lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
        });
        return lines.join('\n');
    }).join('\n\n' + BLOCK_SPLITER + '\n\n');
}
1032934
def cast_str(s, encoding='utf8', errors='strict'):
    """"""
    if isinstance(s, bytes):
        return s.decode(encoding, errors)
    elif isinstance(s, str):
        return s
    else:
        raise TypeError("Expected unicode or bytes, got %r" % s)
1121567
def to_twos_comp(val, bits):
    """"""
    if not val.startswith('-'):
        return to_int(val)
    value = _invert(to_bin_str_from_int_string(bits, bin(to_int(val[1:]))))
    return int(value, 2) + 1
965672
def fromBinaryString(value):
        
        bitNo = 8
        byte = 0
        r = []
        for v in value:
            if bitNo:
                bitNo -= 1
            else:
                bitNo = 7
                r.append(byte)
                byte = 0
            if v in ('0', '1'):
                v = int(v)
            else:
                raise error.PyAsn1Error(
                    'Non-binary OCTET STRING initializer %s' % (v,)
                )
            byte |= v << bitNo

        r.append(byte)

        return octets.ints2octs(r)
1081898
def string(v):
    """"""
    if nodesetp(v):
        if not v:
            return u''
        return string_value(v[0])
    elif numberp(v):
        if v == float('inf'):
            return u'Infinity'
        elif v == float('-inf'):
            return u'-Infinity'
        elif str(v) == 'nan':
            return u'NaN'
        elif int(v) == v and v <= 0xffffffff:
            v = int(v)
        return unicode(v)
    elif booleanp(v):
        return u'true' if v else u'false'
    return v
1060154
function bintobinoutput(bin){
  var len = bin.length;
  var binoutput = String();
  for(var i=0; i<len; i++){
    if((i > 0) && !(i%8)){binoutput = " " + binoutput;}
    if(bin[len - 1 - i]){binoutput = "1" + binoutput;}else{binoutput = "0" + binoutput;}
  }
  // todo: make faster
  return binoutput;
}
1274745
def get_pipe_series_output(commands: Sequence[str],
                           stdinput: BinaryIO = None) -> bytes:
    
    # Python arrays indexes are zero-based, i.e. an array is indexed from
    # 0 to len(array)-1.
    # The range/xrange commands, by default, start at 0 and go to one less
    # than the maximum specified.

    # print commands
    processes = []  # type: List[subprocess.Popen]
    for i in range(len(commands)):
        if i == 0:  # first processes
            processes.append(
                subprocess.Popen(
                    shlex.split(commands[i]),
                    stdin=subprocess.PIPE,
                    stdout=subprocess.PIPE
                )
            )
        else:  # subsequent ones
            processes.append(
                subprocess.Popen(
                    shlex.split(commands[i]),
                    stdin=processes[i - 1].stdout,
                    stdout=subprocess.PIPE
                )
            )
    return processes[len(processes) - 1].communicate(stdinput)[0]
663657
def from_series(cls, series, offset=0):
        
        return cls(data=series.data, index=series.index, data_name=series.data_name, index_name=series.index_name,
                   sort=series.sort, offset=offset)
809430
def byte_to_bitstring(byte):
    """"""
    assert 0 <= byte <= 0xff
    bits = [int(x) for x in list(bin(byte + 0x100)[3:])]
    return bits
1141433
def _keynat(string):
    
    r = []
    for c in string:
        if c.isdigit():
            if r and isinstance(r[-1], int):
                r[-1] = r[-1] * 10 + int(c)
            else:
                r.append(int(c))
        else:
            r.append(9 + ord(c))
    return r
923413
def _split(string, splitters):
    """"""
    part = ''
    for character in string:
        if character in splitters:
            yield part
            part = ''
        else:
            part += character
    yield part