diff --git a/examples/range_example.py b/examples/range_example.py index 4110562..8228d81 100644 --- a/examples/range_example.py +++ b/examples/range_example.py @@ -36,4 +36,4 @@ # dataframe.info() # dataframe.memory_usage(deep=True) -# .set_index(['1','2'], inplace=True) \ No newline at end of file +# .set_index(['1', '2'], inplace=True) diff --git a/examples/shortest_path_example.py b/examples/shortest_path_example.py index c53de6e..0b73fe2 100644 --- a/examples/shortest_path_example.py +++ b/examples/shortest_path_example.py @@ -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) @@ -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:') diff --git a/pandana/network.py b/pandana/network.py index fe3086c..6842edd 100644 --- a/pandana/network.py +++ b/pandana/network.py @@ -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 @@ -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 diff --git a/pandana/utils.py b/pandana/utils.py index b3ef06f..c2507c1 100644 --- a/pandana/utils.py +++ b/pandana/utils.py @@ -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 diff --git a/setup.py b/setup.py index 4aba91e..af42b2b 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ ############################################### -## Building the C++ extension +# Building the C++ extension ############################################### extra_compile_args = ["-w", "-std=c++11", "-O3"] @@ -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"