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
Initial range query
smmaurer authored and ljwolf committed Jul 9, 2021
commit c50bdc16db646b63652a6aaac755b3844a435ae2
40 changes: 40 additions & 0 deletions examples/range_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import print_function

import os.path
import sys
import time

import numpy as np
import pandas as pd
import pandana.network as pdna

if len(sys.argv) > 1:
# allow test file to be passed as an argument
storef = sys.argv[1]
else:
# if no argument provided look for it in the test data
storef = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'../pandana/tests/osm_sample.h5'))

if not os.path.isfile(storef):
raise IOError('Could not find test input file: {!r}'.format(storef))

print('Building network from file: {!r}'.format(storef))

store = pd.HDFStore(storef, "r")
nodes, edges = store.nodes, store.edges
net = pdna.Network(nodes.x, nodes.y, edges["from"], edges.to,
edges[["weight"]])
store.close()
print()

# Demonstrate "nodes in range" code - the largest connected subgraph here has 477 nodes,
# per the unit tests

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

print(net.nodes_in_range(1, 500))

9 changes: 9 additions & 0 deletions pandana/network.py
Original file line number Diff line number Diff line change
@@ -386,6 +386,15 @@ def precompute(self, distance):
"""
self.net.precompute_range(distance)

def nodes_in_range(self, node, radius, imp_name=None):
"""
"""
# NEED TO MAP TO INTERNAL NODE INDEX

imp_num = self._imp_name_to_num(imp_name)

return self.net.nodes_in_range(node, radius, imp_num)

def _imp_name_to_num(self, imp_name):
if imp_name is None:
assert len(self.impedance_names) == 1,\
19 changes: 19 additions & 0 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
@@ -81,6 +81,25 @@ Accessibility::precomputeRangeQueries(float radius) {
}


vector<pair<int, float>>
Accessibility::Range(int srcnode, float radius, int graphno) {
DistanceVec tmp;
DistanceVec &distances = tmp;

// use cached results if available
if (dmsradius > 0 && radius <= dmsradius) {
distances = dms[graphno][srcnode];
} else {
ga[graphno]->Range(
srcnode,
radius,
omp_get_thread_num(),
tmp);
}
return vector<pair<int, float>> (tmp.begin(), tmp.end());
}


vector<int>
Accessibility::Route(int src, int tgt, int graphno) {
vector<NodeID> ret = this->ga[graphno]->Route(src, tgt);
2 changes: 1 addition & 1 deletion src/accessibility.h
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ class Accessibility {
int graphno = 0);

// get nodes with the range
DistanceVec Range(int srcnode, float radius, int graphno = 0);
vector<pair<int, float>> Range(int srcnode, float radius, int graphno = 0);

// shortest path between two points
vector<int> Route(int src, int tgt, int graphno = 0);
6 changes: 6 additions & 0 deletions src/cyaccess.pyx
Original file line number Diff line number Diff line change
@@ -27,6 +27,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[int, float]] Range(int, float, int)
void precomputeRangeQueries(double)


@@ -192,5 +193,10 @@ cdef class cyaccess:
"""
return self.access.Distances(srcnodes, destnodes, impno)

def nodes_in_range(self, int srcnode, float radius, int impno=0):
"""
"""
return self.access.Range(srcnode, radius, impno)

def precompute_range(self, double radius):
self.access.precomputeRangeQueries(radius)