08884e278540cc3b3cbe780f6695bc8cbb4c05b6,osmnx/utils_graph.py,,add_edge_lengths,#Any#Any#,146

Before Change


    
    // extract the edges" endpoint nodes" coordinates
    try:
        coords = (
            (u, v, k, G.nodes[u]["y"], G.nodes[u]["x"], G.nodes[v]["y"], G.nodes[v]["x"])
            for u, v, k in G.edges
        )
    except KeyError:  // pragma: no cover
        missing_nodes = {
            str(i)
            for u, v, _ in G.edges(keys=True)
            if not (G.nodes[u] or G.nodes[u])
            for i in (u, v)
            if not G.nodes[i]
        }
        missing_str = ", ".join(missing_nodes)
        raise KeyError(f"Edge(s) missing nodes {missing_str} possibly due to clipping issue")

    // turn the coordinates into a DataFrame indexed by u, v, k
    cols = ["u", "v", "k", "u_y", "u_x", "v_y", "v_x"]
    df = pd.DataFrame(coords, columns=cols).set_index(["u", "v", "k"])

    // calculate great circle distances, fill nulls with zeros, then round
    dists = distance.great_circle_vec(df["u_y"], df["u_x"], df["v_y"], df["v_x"])

After Change


    // first load all the edges" origin and destination coordinates as a
    // dataframe indexed by u, v, key
    try:
        coords = np.array(
            [
                (u, v, k, G.nodes[u]["y"], G.nodes[u]["x"], G.nodes[v]["y"], G.nodes[v]["x"])
                for u, v, k in G.edges(keys=True)
            ]
        )
    except KeyError:  // pragma: no cover
        missing_nodes = {
            str(i)
            for u, v, _ in G.edges(keys=True)
            if not (G.nodes[u] or G.nodes[u])
            for i in (u, v)
            if not G.nodes[i]
        }
        missing_str = ", ".join(missing_nodes)
        raise KeyError(f"Edge(s) missing nodes {missing_str} possibly due to clipping issue")

    df_coords = pd.DataFrame(coords, columns=["u", "v", "k", "u_y", "u_x", "v_y", "v_x"])
    df_coords[["u", "v", "k"]] = df_coords[["u", "v", "k"]].astype(np.int64)
    df_coords = df_coords.set_index(["u", "v", "k"])

    // then calculate the great circle distance with the vectorized function
    gc_distances = distance.great_circle_vec(
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: gboeing/osmnx
Commit Name: 08884e278540cc3b3cbe780f6695bc8cbb4c05b6
Time: 2020-12-02
Author: boeing@usc.edu
File Name: osmnx/utils_graph.py
Class Name:
Method Name: add_edge_lengths


Project Name: gboeing/osmnx
Commit Name: c178e788a3e34a74a3facff5848baa374f4506fa
Time: 2021-03-13
Author: boeing@usc.edu
File Name: osmnx/stats.py
Class Name:
Method Name: circuity_avg


Project Name: gboeing/osmnx
Commit Name: 4e2a294ef733417631dbb90f586127a24a043a30
Time: 2020-11-19
Author: boeing@usc.edu
File Name: osmnx/utils_graph.py
Class Name:
Method Name: add_edge_lengths