Convert an OrderedDict containing C values to a 1D array.
175500
def C_dict2array(C):
    """"""
    return np.hstack([np.asarray(C[k]).ravel() for k in C_keys])
1371770
def dicts_from_table(table, keys=None):
    """"""
    lod = []
    for row in table:
        if not keys:
            keys = row
            if not all((k not in (None, '') or bool(k.strip())) for k in keys):
                keys = None
            continue
        lod += [OrderedDict((k, v) for k, v in zip(keys, row))]
    return lod
1195445
def to_dict_list(df, use_ordered_dict=True):
    
    if use_ordered_dict:
        dict = OrderedDict

    columns = df.columns
    data = list()
    for tp in itertuple(df):
        data.append(dict(zip(columns, tp)))
    return data
264108
def _asdict(self):
        """"""
        return OrderedDict((f.name, getattr(self, f.name))
                           for f in self._struct)
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)
1095445
def to_ubyte_array(barray):
    """"""
    bs = (ctypes.c_ubyte * len(barray))()
    pack_into('%ds' % len(barray), bs, 0, barray)

    return bs
659506
def read_array(fname, sep=','):
    
    """
    with open(fname) as f:
        records = []
        for line in f:
            row = line.split(sep)
            record = [list(map(float, col.split())) for col in row]
            records.append(record)
        return numpy.array(records)
838032
def _split_dict(dic):
    '''
    '''
    keys = sorted(dic.keys())
    return keys, [dic[k] for k in keys]
25425
def _dtype_array(self):
        """"""
        attrtype = []
        attrdiff = []

        for key in self._headers:
            if self.attr[key][0] == 'continuous':
                attrtype.append(1)
            else:
                attrtype.append(0)
            attrdiff.append(self.attr[key][3])

        attrtype = np.array(attrtype)
        cidx = np.where(attrtype == 1)[0]
        didx = np.where(attrtype == 0)[0]

        attrdiff = np.array(attrdiff)

        return attrdiff, cidx, didx
804623
def todict(self):
        """"""
        return OrderedDict((name, self[i]) for i, name in enumerate(self._fields))
1093049
def _set_arrayorder(obj, arrayorder='C'):
    
    msg = "Arg arrayorder must be in ['C','F']"
    assert arrayorder in ['C','F'], msg

    d = obj.to_dict(strip=-1)
    account = {'Success':[], 'Failed':[]}
    for k, v in d.items():
        if type(v) is np.array and v.ndim>1:
            try:
                if arrayorder=='C':
                    d[k] = np.ascontiguousarray(v)
                else:
                    d[k] = np.asfortranarray(v)
                account['Success'].append(k)
            except Exception as err:
                warnings.warn(str(err))
                account['Failed'].append(k)

    return d, account
1266090
def _as_array(self, fmt):
        ''''''
        assert self.dimensions, \
            '{}: cannot get value as {} array!'.format(self.name, fmt)
        elems = array.array(fmt)
        elems.fromstring(self.bytes)
        return np.array(elems).reshape(self.dimensions)
189860
def order_to_dict(order):
    """"""
    default = Order()
    return {field: val for field, val in vars(order).items() if val != getattr(default, field, None)}
901456
def list_to_1d_numpy(data, dtype=np.float32, name='list'):
    """"""
    if is_numpy_1d_array(data):
        if data.dtype == dtype:
            return data
        else:
            return data.astype(dtype=dtype, copy=False)
    elif is_1d_list(data):
        return np.array(data, dtype=dtype, copy=False)
    elif isinstance(data, Series):
        return data.values.astype(dtype)
    else:
        raise TypeError("Wrong type({0}) for {1}.\n"
                        "It should be list, numpy 1-D array or pandas Series".format(type(data).__name__, name))
188689
def _sortObjects(orderby='created', **kwargs):
    """"""
    o = []
    
    for m in kwargs.values():
        for l in iter(m):
            o.append(l)
    o = list(set(o))
    sortfunc = _sortByCreated if orderby == 'created' else _sortByModified
    if six.PY2:
        o.sort(sortfunc)
    else:
        o.sort(key=functools.cmp_to_key(sortfunc))

    return o
249539
def toarray(self):
        
        return asarray([value.toarray() for (key, value) in sorted(self.transformations.items())])
408547
def to_OrderedDict(self, include_null=True):
        
        if include_null:
            return OrderedDict(self.items())
        else:
            items = list()
            for c in self.__table__._columns:
                try:
                    items.append((c.name, self.__dict__[c.name]))
                except KeyError:
                    pass
            return OrderedDict(items)