Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
smmaurer committed Jul 25, 2023
1 parent 58bae73 commit 836b14d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/range_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@

# dataframe.info()
# dataframe.memory_usage(deep=True)
# .set_index(['1','2'], inplace=True)
# .set_index(['1', '2'], inplace=True)
14 changes: 7 additions & 7 deletions examples/shortest_path_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

net.set(pd.Series(net.node_ids))
s = net.aggregate(10000, type='count')
connected_nodes = s[s==477]
connected_nodes = s[s == 477]

n = 10000
nodes_a = np.random.choice(connected_nodes.index, n)
Expand All @@ -60,19 +60,19 @@
print(nodes_a[0])
print(nodes_b[0])

print(net.shortest_path(nodes_a[0],nodes_b[0]))
print(net.shortest_path_length(nodes_a[0],nodes_b[0]))
print(net.shortest_path(nodes_a[0], nodes_b[0]))
print(net.shortest_path_length(nodes_a[0], nodes_b[0]))

print('Shortest path 2:')
print(nodes_a[1])
print(nodes_b[1])

print(net.shortest_path(nodes_a[1],nodes_b[1]))
print(net.shortest_path_length(nodes_a[1],nodes_b[1]))
print(net.shortest_path(nodes_a[1], nodes_b[1]))
print(net.shortest_path_length(nodes_a[1], nodes_b[1]))

print('Repeat with vectorized calculations:')
print(net.shortest_paths(nodes_a[0:2],nodes_b[0:2]))
print(net.shortest_path_lengths(nodes_a[0:2],nodes_b[0:2]))
print(net.shortest_paths(nodes_a[0:2], nodes_b[0:2]))
print(net.shortest_path_lengths(nodes_a[0:2], nodes_b[0:2]))

# Performance comparison
print('Performance comparison for 10k distance calculations:')
Expand Down
14 changes: 7 additions & 7 deletions pandana/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def shortest_path_length(self, node_a, node_b, imp_name=None):

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)
"Unsigned integer: shortest path distance is trying to be calculated between\
external %s and %s unconntected nodes" % (node_a, node_b)
)

return len
Expand Down Expand Up @@ -329,11 +329,11 @@ 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))
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

Expand Down
3 changes: 2 additions & 1 deletion pandana/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def reindex(series1, series2):
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)
df = df.reindex(index=idx, columns=idx, fill_value=0)

return df
24 changes: 12 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


###############################################
## Building the C++ extension
# Building the C++ extension
###############################################

extra_compile_args = ["-w", "-std=c++11", "-O3"]
Expand Down Expand Up @@ -77,20 +77,20 @@


cyaccess = Extension(
name='pandana.cyaccess',
sources=[
'src/accessibility.cpp',
'src/graphalg.cpp',
'src/cyaccess.pyx',
'src/contraction_hierarchies/src/libch.cpp'],
language='c++',
include_dirs=['.', np.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)
name='pandana.cyaccess',
sources=[
'src/accessibility.cpp',
'src/graphalg.cpp',
'src/cyaccess.pyx',
'src/contraction_hierarchies/src/libch.cpp'],
language='c++',
include_dirs=['.', np.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)


###############################################
## Standard setup
# Standard setup
###############################################

version = "0.7"
Expand Down

0 comments on commit 836b14d

Please sign in to comment.