3208fe37c6787ef0cd3f2f973a02ad63995042fa,osmnx/bearing.py,,add_edge_bearings,#Any#Any#,61
Before Change
if projection.is_projected(G.graph["crs"]): // pragma: no cover
raise ValueError("graph must be unprojected to add edge bearings")
for u, v, data in G.edges(keys=False, data=True):
if u == v:
// a self-loop has an undefined compass bearing
data["bearing"] = np.nan
else:
// calculate bearing from edge"s origin to its destination
origin_point = (G.nodes[u]["y"], G.nodes[u]["x"])
destination_point = (G.nodes[v]["y"], G.nodes[v]["x"])
bearing = get_bearing(origin_point, destination_point)
data["bearing"] = round(bearing, precision)
return G
def orientation_entropy(Gu, num_bins=36, min_length=0, weight=None):
After Change
// extract edge IDs and corresponding coordinates from their nodes
uvk = tuple(G.edges)
x = G.nodes(data="x")
y = G.nodes(data="y")
coords = np.array([(y[u], x[u], y[v] , x[v]) for u, v, k in uvk])
// calculate bearings then set as edge attributes
bearings = calculate_bearing(coords[:, 0], coords[:, 1], coords[:, 2], coords[:, 3])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: gboeing/osmnx
Commit Name: 3208fe37c6787ef0cd3f2f973a02ad63995042fa
Time: 2021-03-26
Author: boeing@usc.edu
File Name: osmnx/bearing.py
Class Name:
Method Name: add_edge_bearings
Project Name: dmlc/dgl
Commit Name: 455ea48570f1af63b1270c8ccda49fbe3deb9bcc
Time: 2018-12-04
Author: ly979@nyu.edu
File Name: python/dgl/graph.py
Class Name: DGLGraph
Method Name: from_networkx
Project Name: rusty1s/pytorch_geometric
Commit Name: c0458f0c0fb84c27570d91c6a971e29109649fca
Time: 2020-01-06
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/utils/convert.py
Class Name:
Method Name: from_networkx