# Path: urbanaccess/network.py
# class urbanaccess_network(object):
#     def __init__(self,
#                  transit_nodes=pd.DataFrame(),
#                  transit_edges=pd.DataFrame(),
#                  net_connector_edges=pd.DataFrame(),
#                  osm_nodes=pd.DataFrame(),
#                  osm_edges=pd.DataFrame(),
#                  net_nodes=pd.DataFrame(),
#                  net_edges=pd.DataFrame()):
# def _nearest_neighbor(df1, df2):
# def integrate_network(urbanaccess_network, headways=False,
#                       urbanaccess_gtfsfeeds_df=None, headway_statistic='mean'):
# def _add_headway_impedance(ped_to_transit_edges_df, headways_df,
#                            headway_statistic='mean'):
# def _route_id_to_node(stops_df, edges_w_routes):
# def _connector_edges(osm_nodes, transit_nodes, travel_speed_mph=3):
# def _format_pandana_edges_nodes(edge_df, node_df):
# def save_network(urbanaccess_network, filename,
#                  dir=config.settings.data_folder,
#                  overwrite_key=False, overwrite_hdf5=False):
# def load_network(dir=config.settings.data_folder, filename=None):


import pytest
import pandas as pd
from urbanaccess import network
                     '2_transit_a', 1,
                     '3_transit_a', 1,
                     '4_transit_a', 3],
            'to': [2, '1_transit_a',
                   1, '2_transit_a',
                   1, '3_transit_a',
                   3, '4_transit_a'],
            'weight': [2.521901, 2.521901, 0.766106, 0.766106,
                       5.317242, 5.317242, 29.690540, 29.690540],
            'net_type': ['transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit']}

    index = range(8)
    expected_connector_edge = pd.DataFrame(data, index)
    return expected_connector_edge


def test_nearest_neighbor(osm_nodes_df, transit_nodes_df,
                          expected_transit_nodes_neighbor_df):
    transit_nodes_df['nearest_osm_node'] = network._nearest_neighbor(
        osm_nodes_df[['x', 'y']],
        transit_nodes_df[['x', 'y']])

    assert expected_transit_nodes_neighbor_df.equals(transit_nodes_df)


def test_connector_edges(osm_nodes_df, transit_nodes_df,
                         expected_connector_edge_df):

# Path: urbanaccess/network.py
# class urbanaccess_network(object):
#     def __init__(self,
#                  transit_nodes=pd.DataFrame(),
#                  transit_edges=pd.DataFrame(),
#                  net_connector_edges=pd.DataFrame(),
#                  osm_nodes=pd.DataFrame(),
#                  osm_edges=pd.DataFrame(),
#                  net_nodes=pd.DataFrame(),
#                  net_edges=pd.DataFrame()):
# def _nearest_neighbor(df1, df2):
# def integrate_network(urbanaccess_network, headways=False,
#                       urbanaccess_gtfsfeeds_df=None, headway_statistic='mean'):
# def _add_headway_impedance(ped_to_transit_edges_df, headways_df,
#                            headway_statistic='mean'):
# def _route_id_to_node(stops_df, edges_w_routes):
# def _connector_edges(osm_nodes, transit_nodes, travel_speed_mph=3):
# def _format_pandana_edges_nodes(edge_df, node_df):
# def save_network(urbanaccess_network, filename,
#                  dir=config.settings.data_folder,
#                  overwrite_key=False, overwrite_hdf5=False):
# def load_network(dir=config.settings.data_folder, filename=None):


# Path: urbanaccess/tests/test_network.py
import pytest
import pandas as pd
from urbanaccess import network

                     '2_transit_a', 1,
                     '3_transit_a', 1,
                     '4_transit_a', 3],
            'to': [2, '1_transit_a',
                   1, '2_transit_a',
                   1, '3_transit_a',
                   3, '4_transit_a'],
            'weight': [2.521901, 2.521901, 0.766106, 0.766106,
                       5.317242, 5.317242, 29.690540, 29.690540],
            'net_type': ['transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit',
                         'transit to osm', 'osm to transit']}

    index = range(8)
    expected_connector_edge = pd.DataFrame(data, index)
    return expected_connector_edge


def test_nearest_neighbor(osm_nodes_df, transit_nodes_df,
                          expected_transit_nodes_neighbor_df):
    transit_nodes_df['nearest_osm_node'] = network._nearest_neighbor(
        osm_nodes_df[['x', 'y']],
        transit_nodes_df[['x', 'y']])

    assert expected_transit_nodes_neighbor_df.equals(transit_nodes_df)


def test_connector_edges(osm_nodes_df, transit_nodes_df,
                         expected_connector_edge_df):

    net_connector_edges = network._connector_edges(osm_nodes_df,