Skip to content

Commit

Permalink
Merge branch 'dev' into v0.7-prep
Browse files Browse the repository at this point in the history
  • Loading branch information
smmaurer committed Jul 25, 2023
2 parents 6cbaa3e + 9616c2c commit 58bae73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pandana/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ def shortest_path_length(self, node_a, node_b, imp_name=None):

len = self.net.shortest_path_distance(node_a, node_b, imp_num)

if len == 4294967.295:
warnings.warn(
"Unsigned integer: shortest path distance is trying to be calculated between\
external %s and %s unconntected nodes"%(node_a, node_b)
)

return len

def shortest_path_lengths(self, nodes_a, nodes_b, imp_name=None):
Expand Down Expand Up @@ -322,6 +328,13 @@ def shortest_path_lengths(self, nodes_a, nodes_b, imp_name=None):

lens = self.net.shortest_path_distances(nodes_a_idx, nodes_b_idx, imp_num)

if 4294967.295 in lens:
unconnected_idx = [i for i,v in enumerate(lens) if v == 4294967.295]
unconnected_nodes = [(nodes_a[i],nodes_b[i]) for i in unconnected_idx]
warnings.warn(
"Unsigned integer: shortest path distance is trying to be calculated \
between the following external unconnected nodes: %s"%(unconnected_nodes))

return lens

def set(self, node_ids, variable=None, name="tmp"):
Expand Down
7 changes: 7 additions & 0 deletions pandana/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ def reindex(series1, series2):
right_index=True,
how="left")
return df.right

def adjacency_matrix(edges_df, plot_matrix=False):
df = pd.crosstab(edges_df['from'], edges_df['to'])
idx = df.columns.union(df.index)
df = df.reindex(index = idx, columns=idx, fill_value=0)

return df

0 comments on commit 58bae73

Please sign in to comment.