vflow/convert.py
def sep_dicts(d: dict, n_out: int = 1):
    '''converts dictionary with value being saved as an iterable into multiple dictionaries
    Assumes every value has same length n_out

    Params
    ------
    d: {k1: (x1, y1), k2: (x2, y2), ...,  '__prev__': p}
    n_out: the number of dictionaries to separate d into

    Returns
    -------
    sep_dicts: [{k1: x1, k2: x2, ..., '__prev__': p}, {k1: y1, k2: y2, '__prev__': p}]
    '''
    # empty dict -- return empty dict
    if n_out == 1:
        return d
    else:
        # try separating dict into multiple dicts
        sep_dicts_id = str(uuid4()) # w/ high prob, uuid4 is unique
        sep_dicts = [dict() for x in range(n_out)]
        for key, value in d.items():
            if key != PREV_KEY:
                for i in range(n_out):
                    # assumes the correct sub-key for item i is in the i-th position
                    new_key = (key[i],) + key[n_out:]
                    new_key[-1]._sep_dicts_id = sep_dicts_id
                    sep_dicts[i][new_key] = value[i]

        # add back prev
        prev = d[PREV_KEY]
        for i in range(n_out):
            sep_dicts[i][PREV_KEY] = prev
        return sep_dicts
converts dictionary with value being saved as an iterable into multiple dictionaries
    Assumes every value has same length n_out

    Params
    ------
    d: {k1: (x1, y1), k2: (x2, y2), ...,  '__prev__': p}
    n_out: the number of dictionaries to separate d into

    Returns
    -------
    sep_dicts: [{k1: x1, k2: x2, ..., '__prev__': p}, {k1: y1, k2: y2, '__prev__': p}]
    
converts dictionary with value being saved as an iterable into multiple dictionaries
Assumes every value has same length n_out

Params



Returns


converts dictionary with value being saved as an iterable into multiple dictionaries Assumes every value has same length n_out Params Returns
def sep_dicts(d: dict, n_out: int = 1):
    if n_out == 1:
        return d
    else:
        sep_dicts_id = str(uuid4()) 
        sep_dicts = [dict() for x in range(n_out)]
        for key, value in d.items():
            if key != PREV_KEY:
                for i in range(n_out):
                    new_key = (key[i],) + key[n_out:]
                    new_key[-1]._sep_dicts_id = sep_dicts_id
                    sep_dicts[i][new_key] = value[i]
        prev = d[PREV_KEY]
        for i in range(n_out):
            sep_dicts[i][PREV_KEY] = prev
        return sep_dicts
def sep_dicts ( d : dict , n_out : int = 1 ) : if n_out == 1 : return d else : sep_dicts_id = str ( uuid4 ( ) ) sep_dicts = [ dict ( ) for x in range ( n_out ) ] for key , value in d . items ( ) : if key != PREV_KEY : for i in range ( n_out ) : new_key = ( key [ i ] , ) + key [ n_out : ] new_key [ - 1 ] . _sep_dicts_id = sep_dicts_id sep_dicts [ i ] [ new_key ] = value [ i ] prev = d [ PREV_KEY ] for i in range ( n_out ) : sep_dicts [ i ] [ PREV_KEY ] = prev return sep_dicts
converts dictionary with value being saved as an iterable into multiple dictionaries
Assumes every value has same length n_out
converts dictionary with value being saved as an iterable into multiple dictionaries Assumes every value has same length n_out
'''converts dictionary with value being saved as an iterable into multiple dictionaries
    Assumes every value has same length n_out

    Params
    ------
    d: {k1: (x1, y1), k2: (x2, y2), ...,  '__prev__': p}
    n_out: the number of dictionaries to separate d into

    Returns
    -------
    sep_dicts: [{k1: x1, k2: x2, ..., '__prev__': p}, {k1: y1, k2: y2, '__prev__': p}]
    ''' # empty dict -- return empty dict # try separating dict into multiple dicts # w/ high prob, uuid4 is unique # assumes the correct sub-key for item i is in the i-th position # add back prev
d
dict
n_out
int