labtools/_src/util.py
def flatten_dict(d, parent_key='', sep='/', sort=True):
  """ Flatten a nested dictionary

  Flattens a nested dictionary by joining keys at each depth using `sep`.

  Examples:
    >>> flatten_dict({'a': {'b': 2}, c: 1})
        {'a.b': 2, 'c':1}
  """
  items = []
  for k, v in d.items():
    new_key = parent_key + sep + k if parent_key else k
    if isinstance(v, MutableMapping):
      items.extend(flatten_dict(v, new_key, sep=sep, sort=False).items())
    else:
      items.append((new_key, v))
  return OrderedDict(sorted(items, key=lambda x: x[0])) if sort else dict(items)
 Flatten a nested dictionary

  Flattens a nested dictionary by joining keys at each depth using `sep`.

  Examples:
    >>> flatten_dict({'a': {'b': 2}, c: 1})
        {'a.b': 2, 'c':1}
  
Flatten a nested dictionary
Flattens a nested dictionary by joining keys at each depth using `sep`.
Flatten a nested dictionary Flattens a nested dictionary by joining keys at each depth using ` sep ` .
def flatten_dict(d, parent_key='', sep='/', sort=True):
  items = []
  for k, v in d.items():
    new_key = parent_key + sep + k if parent_key else k
    if isinstance(v, MutableMapping):
      items.extend(flatten_dict(v, new_key, sep=sep, sort=False).items())
    else:
      items.append((new_key, v))
  return OrderedDict(sorted(items, key=lambda x: x[0])) if sort else dict(items)
def flatten_dict ( d , parent_key = '' , sep = '/' , sort = True ) : items = [ ] for k , v in d . items ( ) : new_key = parent_key + sep + k if parent_key else k if isinstance ( v , MutableMapping ) : items . extend ( flatten_dict ( v , new_key , sep = sep , sort = False ) . items ( ) ) else : items . append ( ( new_key , v ) ) return OrderedDict ( sorted ( items , key = lambda x : x [ 0 ] ) ) if sort else dict ( items )
Flatten a nested dictionary
Flattens a nested dictionary by joining keys at each depth using `sep`.
Flatten a nested dictionary Flattens a nested dictionary by joining keys at each depth using ` sep ` .
""" Flatten a nested dictionary

  Flattens a nested dictionary by joining keys at each depth using `sep`.

  Examples:
    >>> flatten_dict({'a': {'b': 2}, c: 1})
        {'a.b': 2, 'c':1}
  """
d
parent_key
sep
sort
examples
None