def _validate_ding0_lv_grid_import(grids, ding0_grid, lv_grid_mapping):
    """Verify imported data with original data from Ding0

    Parameters
    ----------
    grids: list of LVGrid
        LV Grid data (eDisGo)
    ding0_grid: ding0.MVGridDing0
        Ding0 MV grid object
    lv_grid_mapping: dict
        Defines relationship between Ding0 and eDisGo grid objects

    Notes
    -----
    The data validation excludes grid components located in aggregated load
    areas as these are represented differently in eDisGo.

    Returns
    -------
    dict
        Dict showing data integrity for each type of grid component
    """

    integrity_checks = ['branch_tee', 'lv_transformer',
                        'generator', 'load','line']

    data_integrity = {}

    for grid in grids:

        data_integrity.update({grid:{_: {'ding0': None, 'edisgo': None, 'msg': None}
                           for _ in integrity_checks}})

        # Check number of branch tees
        data_integrity[grid]['branch_tee']['ding0'] = len(
            lv_grid_mapping[grid]._cable_distributors)
        data_integrity[grid]['branch_tee']['edisgo'] = len(
            grid.graph.nodes_by_attribute('branch_tee'))

        # Check number of LV transformers
        data_integrity[grid]['lv_transformer']['ding0'] = len(
            list(lv_grid_mapping[grid].station().transformers()))
        data_integrity[grid]['lv_transformer']['edisgo'] = len(
            grid.station.transformers)

        # Check number of generators
        data_integrity[grid]['generator']['edisgo'] = len(
            grid.generators)
        data_integrity[grid]['generator']['ding0'] = len(
            list(lv_grid_mapping[grid].generators()))

        # Check number of loads
        data_integrity[grid]['load']['edisgo'] = len(
            grid.graph.nodes_by_attribute('load'))
        data_integrity[grid]['load']['ding0'] = len(
            list(lv_grid_mapping[grid].loads()))

        # Check number of lines outside aggregated LA
        data_integrity[grid]['line']['edisgo'] = len(
            list(grid.graph.lines()))
        data_integrity[grid]['line']['ding0'] = len(
            [_ for _ in lv_grid_mapping[grid].graph_edges()
             if not _['branch'].connects_aggregated])

    # raise an error if data does not match
    for grid in grids:
        for c in integrity_checks:
            if data_integrity[grid][c]['edisgo'] != data_integrity[grid][c]['ding0']:
                raise ValueError(
                    'Unequal number of objects in grid {grid} for {c}. '
                    '\n\tDing0:\t{ding0_no}'
                    '\n\teDisGo:\t{edisgo_no}'.format(
                        grid=grid,
                        c=c,
                        ding0_no=data_integrity[grid][c]['ding0'],
                        edisgo_no=data_integrity[grid][c]['edisgo']))
def _validate_ding0_lv_grid_import ( grids , ding0_grid , lv_grid_mapping ) : integrity_checks = [ 'branch_tee' , 'lv_transformer' , 'generator' , 'load' , 'line' ] data_integrity = { } for grid in grids : data_integrity . update ( { grid : { _ : { 'ding0' : None , 'edisgo' : None , 'msg' : None } for _ in integrity_checks } } ) data_integrity [ grid ] [ 'branch_tee' ] [ 'ding0' ] = len ( lv_grid_mapping [ grid ] . _cable_distributors ) data_integrity [ grid ] [ 'branch_tee' ] [ 'edisgo' ] = len ( grid . graph . nodes_by_attribute ( 'branch_tee' ) ) data_integrity [ grid ] [ 'lv_transformer' ] [ 'ding0' ] = len ( list ( lv_grid_mapping [ grid ] . station ( ) . transformers ( ) ) ) data_integrity [ grid ] [ 'lv_transformer' ] [ 'edisgo' ] = len ( grid . station . transformers ) data_integrity [ grid ] [ 'generator' ] [ 'edisgo' ] = len ( grid . generators ) data_integrity [ grid ] [ 'generator' ] [ 'ding0' ] = len ( list ( lv_grid_mapping [ grid ] . generators ( ) ) ) data_integrity [ grid ] [ 'load' ] [ 'edisgo' ] = len ( grid . graph . nodes_by_attribute ( 'load' ) ) data_integrity [ grid ] [ 'load' ] [ 'ding0' ] = len ( list ( lv_grid_mapping [ grid ] . loads ( ) ) ) data_integrity [ grid ] [ 'line' ] [ 'edisgo' ] = len ( list ( grid . graph . lines ( ) ) ) data_integrity [ grid ] [ 'line' ] [ 'ding0' ] = len ( [ _ for _ in lv_grid_mapping [ grid ] . graph_edges ( ) if not _ [ 'branch' ] . connects_aggregated ] ) for grid in grids : for c in integrity_checks : if data_integrity [ grid ] [ c ] [ 'edisgo' ] != data_integrity [ grid ] [ c ] [ 'ding0' ] : raise ValueError ( 'Unequal number of objects in grid {grid} for {c}. ' '\n\tDing0:\t{ding0_no}' '\n\teDisGo:\t{edisgo_no}' . format ( grid = grid , c = c , ding0_no = data_integrity [ grid ] [ c ] [ 'ding0' ] , edisgo_no = data_integrity [ grid ] [ c ] [ 'edisgo' ] ) )
Verify imported data with original data from Ding0

    Parameters
    ----------
    grids: list of LVGrid
        LV Grid data (eDisGo)
    ding0_grid: ding0.MVGridDing0
        Ding0 MV grid object
    lv_grid_mapping: dict
        Defines relationship between Ding0 and eDisGo grid objects

    Notes
    -----
    The data validation excludes grid components located in aggregated load
    areas as these are represented differently in eDisGo.

    Returns
    -------
    dict
        Dict showing data integrity for each type of grid component