def merge_partial_elements(element_list):
    """
    merges model elements which collectively all define the model component,
    mostly for multidimensional subscripts

    Parameters
    ----------
    element_list

    Returns
    -------
    """
    outs = dict()  # output data structure
    for element in element_list:
        if element['py_expr'] != "None":  # for
            name = element['py_name']
            if name not in outs:
                # Use 'expr' for Vensim models, and 'eqn' for Xmile (This makes the Vensim equation prettier.)
                eqn = element['expr'] if 'expr' in element else element['eqn']

                outs[name] = {
                    'py_name': element['py_name'],
                    'real_name': element['real_name'],
                    'doc': element['doc'],
                    'py_expr': [element['py_expr']],  # in a list
                    'unit': element['unit'],
                    'subs': [element['subs']],
                    'lims': element['lims'],
                    'eqn': eqn,
                    'kind': element['kind'],
                    'arguments': element['arguments']
                }

            else:
                outs[name]['doc'] = outs[name]['doc'] or element['doc']
                outs[name]['unit'] = outs[name]['unit'] or element['unit']
                outs[name]['lims'] = outs[name]['lims'] or element['lims']
                outs[name]['eqn'] = outs[name]['eqn'] or element['eqn']
                outs[name]['py_expr'] += [element['py_expr']]
                outs[name]['subs'] += [element['subs']]
                outs[name]['arguments'] = element['arguments']

    return list(outs.values())
def merge_partial_elements ( element_list ) : outs = dict ( ) for element in element_list : if element [ 'py_expr' ] != "None" : name = element [ 'py_name' ] if name not in outs : eqn = element [ 'expr' ] if 'expr' in element else element [ 'eqn' ] outs [ name ] = { 'py_name' : element [ 'py_name' ] , 'real_name' : element [ 'real_name' ] , 'doc' : element [ 'doc' ] , 'py_expr' : [ element [ 'py_expr' ] ] , 'unit' : element [ 'unit' ] , 'subs' : [ element [ 'subs' ] ] , 'lims' : element [ 'lims' ] , 'eqn' : eqn , 'kind' : element [ 'kind' ] , 'arguments' : element [ 'arguments' ] } else : outs [ name ] [ 'doc' ] = outs [ name ] [ 'doc' ] or element [ 'doc' ] outs [ name ] [ 'unit' ] = outs [ name ] [ 'unit' ] or element [ 'unit' ] outs [ name ] [ 'lims' ] = outs [ name ] [ 'lims' ] or element [ 'lims' ] outs [ name ] [ 'eqn' ] = outs [ name ] [ 'eqn' ] or element [ 'eqn' ] outs [ name ] [ 'py_expr' ] += [ element [ 'py_expr' ] ] outs [ name ] [ 'subs' ] += [ element [ 'subs' ] ] outs [ name ] [ 'arguments' ] = element [ 'arguments' ] return list ( outs . values ( ) )
merges model elements which collectively all define the model component,
    mostly for multidimensional subscripts

    Parameters
    ----------
    element_list

    Returns
    -------