Convert an IBPy Order object to a dict containing any non-default values.
189860
def order_to_dict(order):
    """"""
    default = Order()
    return {field: val for field, val in vars(order).items() if val != getattr(default, field, None)}
706548
def to_dict(self, remove_nones=False):
        

        if remove_nones:
            return {k: v for k, v in self.to_dict().items() if v is not None}
        else:
            raise NotImplementedError()
914281
def unscale_dict(C):
    """"""
    C_out = {k: _scale_dict[k] * v for k, v in C.items()}
    for k in C_symm_keys[8]:
        C_out['qqql'] = unscale_8(C_out['qqql'])
    return C_out
665611
def _bson_to_dict(data, opts):
    """"""
    try:
        obj_size = _UNPACK_INT(data[:4])[0]
    except struct.error as exc:
        raise InvalidBSON(str(exc))
    if obj_size != len(data):
        raise InvalidBSON("invalid object size")
    if data[obj_size - 1:obj_size] != b"\x00":
        raise InvalidBSON("bad eoo")
    try:
        return _elements_to_dict(data, 4, obj_size - 1, opts)
    except InvalidBSON:
        raise
    except Exception:
        # Change exception type to InvalidBSON but preserve traceback.
        _, exc_value, exc_tb = sys.exc_info()
        reraise(InvalidBSON, exc_value, exc_tb)
476552
def basic_sobject_to_dict(obj):
    
    if not hasattr(obj, '__keylist__'):
        return obj
    data = {}
    fields = obj.__keylist__
    for field in fields:
        val = getattr(obj, field)
        if isinstance(val, list):
            data[field] = []
            for item in val:
                data[field].append(basic_sobject_to_dict(item))
        else:
            data[field] = basic_sobject_to_dict(val)
    return data
1260319
def deep_convert_dict(value):
    
    to_ret = value
    if isinstance(value, OrderedDict):
        to_ret = dict(value)

    try:
        for k, v in to_ret.items():
            to_ret[k] = deep_convert_dict(v)
    except AttributeError:
        pass

    return to_ret
954994
def _ordered(generator, *args, **kwargs):
    """"""
    unordered_dict = {k: v for k, v in generator(*args, **kwargs)}
    keys = sorted(list(dict(unordered_dict).keys()))
    result = OrderedDict()
    for key in keys:
        result[key] = unordered_dict[key]

    return result
359834
def fields_to_dict(fields, type_=OrderedDict):
    """"""
    fields_iterator = iter(fields)
    return type_(zip(fields_iterator, fields_iterator))
1055708
def as_dict(self):
        
        self.clean()
        d = OrderedDict()
        all_props = self.__class__.CONFIG_PROPERTIES
        for attr_name, attr_config in six.iteritems(all_props):
            value = self._config[attr_name]
            attr_type = attr_config.attr_type
            if attr_type:
                if value:
                    if issubclass(attr_type, list):
                        if issubclass(attr_type, NamedTupleList):
                            d[attr_name] = [i._asdict() for i in value]
                        else:
                            d[attr_name] = value[:]
                    elif attr_type is dict:
                        d[attr_name] = dict(value)
            elif value is not NotSet:
                d[attr_name] = value
        return d
235227
def dict_to_object(d):
    """"""
    top = type('CreateSendModel', (object,), d)
    seqs = tuple, list, set, frozenset
    for i, j in d.items():
        if isinstance(j, dict):
            setattr(top, i, dict_to_object(j))
        elif isinstance(j, seqs):
            setattr(top, i, type(j)(dict_to_object(sj) if isinstance(sj, dict) else sj for sj in j))
        else:
            setattr(top, i, j)
    return top
606455
def default(self, obj):
        """"""
        if hasattr(obj, '__dict__'):
            return obj.__dict__.copy()
        elif HAS_NUMPY and isinstance(obj, np.ndarray):
            return obj.copy().tolist()
        else:
            raise TypeError(("Object of type {:s} with value of {:s} is not "
                             "JSON serializable").format(type(obj), repr(obj)))
985676
def default(self, obj):  # pylint: disable=method-hidden
        """"""

        if hasattr(obj, 'strftime'):
            return obj.strftime("%Y-%m-%dT%H:%M:%SZ")
        elif hasattr(obj, 'get_public_dict'):
            return obj.get_public_dict()
        else:
            return json.JSONEncoder.default(self, obj)
1142719
def dict_from_object(obj: object):
    """"""

    # If object is a dict instance, no need to convert.
    return (obj if isinstance(obj, dict)
            else {attr: getattr(obj, attr)
                  for attr in dir(obj) if not attr.startswith('_')})
170718
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'values' in _dict:
            args['values'] = [
                Value._from_dict(x) for x in (_dict.get('values'))
            ]
        else:
            raise ValueError(
                'Required property \'values\' not present in ValueCollection JSON'
            )
        if 'pagination' in _dict:
            args['pagination'] = Pagination._from_dict(_dict.get('pagination'))
        else:
            raise ValueError(
                'Required property \'pagination\' not present in ValueCollection JSON'
            )
        return cls(**args)
340728
def to_dict(cls, obj):
        '''
        '''
        return {
            k: getattr(obj, k)
            for k in dir(obj)
            if cls.serialisable(k, obj)
        }
749623
def to_dict(cls):
        
        return dict((item.name, item.number) for item in iter(cls))
1000011
def dict_to_numpy_dict(obj_dict):
    
    return {key: np.asarray(value) if value is not None else None for key, value in obj_dict.items()}