Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalizing v0.7 #187

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9fca283
GitHub Actions (#153)
smmaurer Dec 8, 2020
7f9b45b
Resolve Windows dtype error (#154)
smmaurer Dec 16, 2020
de0b047
Notebook cleanup
smmaurer Dec 22, 2020
87ef861
Require C++11 (#155)
smmaurer Jan 4, 2021
236b0b1
Binary installers now available on Pip (#157)
smmaurer Mar 15, 2021
4bacf4c
Fix build on non-x86 (#158)
pkubaj Mar 16, 2021
4cc4666
Native support for ARM Macs (#159)
smmaurer Mar 16, 2021
9a6ebfe
Staging v0.6.1 (#160)
smmaurer Mar 19, 2021
3e3d35c
Documentation cleanup (#163)
sablanchard Apr 6, 2021
657406a
Versioning
smmaurer Jan 5, 2021
c50bdc1
Initial range query
smmaurer Jan 5, 2021
abbe120
Cython language_level
smmaurer Jan 7, 2021
bd76d5b
Node id conversion in c++
smmaurer Jan 7, 2021
1d46875
Multiple source nodes
smmaurer Jan 8, 2021
0b57562
Range example
smmaurer Feb 9, 2021
2603c2e
add docstrings
ljwolf Jul 9, 2021
d39f7ee
remove 2.7 and add 3.9
ljwolf Jul 9, 2021
47b99fa
cast output to indexed dataframe
ljwolf Jul 9, 2021
fc37202
drop duplicated node pairs
ljwolf Jul 9, 2021
63f01ff
censor results (cached or otherwise) greater than search radius
ljwolf Jul 9, 2021
7aee012
move radius filter logic to pandas postprocessing
ljwolf Jul 9, 2021
5760c15
add test and blacken
ljwolf Jul 9, 2021
14b20bf
Support mapping_distance with POIs
Rikuoja Aug 30, 2021
afd5759
Change pytables dependency for python 3.10.x up to 3.7
thomastu Apr 27, 2022
b5b62f4
Merge pull request #167 from ljwolf/range-queries
smmaurer Aug 23, 2022
09b51c4
Merge branch 'dev' into patch-1
smmaurer Aug 23, 2022
1e3920f
Merge pull request #178 from thomastu/patch-1
smmaurer Aug 23, 2022
da0965f
New setup.py/pyproject.toml packaging standards (#165)
smmaurer Aug 23, 2022
e5443e1
Merge branch 'dev' of https://github.com/GispoCoding/pandana into Gis…
smmaurer Aug 23, 2022
7529473
Merge branch 'GispoCoding-dev' into dev
smmaurer Aug 23, 2022
88ec50a
Merge branch 'dev' of https://github.com/udst/pandana into dev
smmaurer Aug 23, 2022
0e82a24
Support Pandas 2.0 (#185)
smmaurer Jul 25, 2023
9616c2c
Informative warning for shortest path unsigned integer (#169)
PyMap Jul 25, 2023
9bcebd6
Staging v0.7 release (#186)
smmaurer Jul 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Multiple source nodes
smmaurer authored and ljwolf committed Jul 9, 2021
commit 1d4687556e8456c905b4956ebf3df4aa413d79e1
2 changes: 1 addition & 1 deletion examples/range_example.py
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
#s = net.aggregate(10000, type='count')
#connected_nodes = s[s==477]

print(net.nodes_in_range(53114882, 5.0))
print(net.nodes_in_range([53114882, 53107159], 5.0))

print(net.node_idx.values)
print(net.node_idx.index.values)
6 changes: 3 additions & 3 deletions pandana/network.py
Original file line number Diff line number Diff line change
@@ -386,13 +386,13 @@ def precompute(self, distance):
"""
self.net.precompute_range(distance)

def nodes_in_range(self, node, radius, imp_name=None):
def nodes_in_range(self, nodes, radius, imp_name=None):
"""
"""
imp_num = self._imp_name_to_num(imp_name)
ext_node_ids = self.node_idx.index.values
ext_ids = self.node_idx.index.values

return self.net.nodes_in_range(node, radius, imp_num, ext_node_ids)
return self.net.nodes_in_range(nodes, radius, imp_num, ext_ids)

def _imp_name_to_num(self, imp_name):
if imp_name is None:
43 changes: 25 additions & 18 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
@@ -82,36 +82,43 @@ Accessibility::precomputeRangeQueries(float radius) {
}


vector<pair<long, float>>
Accessibility::Range(int srcnode, float radius, int graphno, vector<long> ext_node_ids) {
vector<vector<pair<long, float>>>
Accessibility::Range(vector<long> srcnodes, float radius, int graphno,
vector<long> ext_ids) {

// Set up a mapping between the external node ids and internal ones
std::unordered_map<long, int> int_ids(ext_node_ids.size());
for (int i = 0; i < ext_node_ids.size(); i++) {
int_ids.insert(pair<long, int>(ext_node_ids[i], i));
std::unordered_map<long, int> int_ids(ext_ids.size());
for (int i = 0; i < ext_ids.size(); i++) {
int_ids.insert(pair<long, int>(ext_ids[i], i));
}

DistanceVec tmp;
DistanceVec &distances = tmp;

// use cached results if available
vector<DistanceVec> dists(srcnodes.size());
if (dmsradius > 0 && radius <= dmsradius) {
distances = dms[graphno][int_ids[srcnode]];
} else {
ga[graphno]->Range(
int_ids[srcnode],
radius,
omp_get_thread_num(),
tmp);
for (int i = 0; i < srcnodes.size(); i++) {
dists[i] = dms[graphno][int_ids[srcnodes[i]]];
}
}
else {
#pragma omp parallel
#pragma omp for schedule(guided)
for (int i = 0; i < srcnodes.size(); i++) {
ga[graphno]->Range(int_ids[srcnodes[i]], radius,
omp_get_thread_num(), dists[i]);
}
}

// todo: check that results are returned from cache correctly
// todo: check that performing an aggregation creates cache

// Convert back to external node ids
vector<pair<long, float>> output(distances.size());
for (int i = 0; i < distances.size(); i++) {
output[i] = std::make_pair(ext_node_ids[distances[i].first], distances[i].second);
vector<vector<pair<long, float>>> output(dists.size());
for (int i = 0; i < dists.size(); i++) {
output[i].resize(dists[i].size());
for (int j = 0; j < dists[i].size(); j++) {
output[i][j] = std::make_pair(ext_ids[dists[i][j].first],
dists[i][j].second);
}
}
return output;
}
6 changes: 3 additions & 3 deletions src/accessibility.h
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@ class Accessibility {
string decay,
int graphno = 0);

// get nodes with the range
vector<pair<long, float>> Range(int srcnode, float radius, int graphno,
vector<long> ext_node_ids);
// get nodes with a range for a specific list of source nodes
vector<vector<pair<long, float>>> Range(vector<long> srcnodes, float radius,
int graphno, vector<long> ext_ids);

// shortest path between two points
vector<int> Route(int src, int tgt, int graphno = 0);
8 changes: 4 additions & 4 deletions src/cyaccess.pyx
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ cdef extern from "accessibility.h" namespace "MTC::accessibility":
vector[vector[int]] Routes(vector[long], vector[long], int)
double Distance(int, int, int)
vector[double] Distances(vector[long], vector[long], int)
vector[pair[long, float]] Range(int, float, int, vector[long])
vector[vector[pair[long, float]]] Range(vector[long], float, int, vector[long])
void precomputeRangeQueries(double)


@@ -198,8 +198,8 @@ cdef class cyaccess:
def precompute_range(self, double radius):
self.access.precomputeRangeQueries(radius)

def nodes_in_range(self, int srcnode, float radius, int impno,
np.ndarray[long] ext_node_ids):
def nodes_in_range(self, vector[long] srcnodes, float radius, int impno,
np.ndarray[long] ext_ids):
"""
"""
return self.access.Range(srcnode, radius, impno, ext_node_ids)
return self.access.Range(srcnodes, radius, impno, ext_ids)