Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Jan 29, 2020
2 parents 69ca602 + d3df1e5 commit 537ef1a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
7 changes: 1 addition & 6 deletions cityseer/algos/centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,8 @@ def local_centrality(node_data: np.ndarray,
# only process in one direction
if to_idx < src_idx:
continue
# identify true routes from ghosted routes
src_ghosted = nodes_ghosted[src_idx]
to_ghosted = nodes_ghosted[to_idx]
true_route = not src_ghosted and not to_ghosted
# NODE WORKFLOW
# don't count routes originating or ending at ghosted nodes
if true_route and betw_nodes:
if betw_nodes:
# betweenness - only counting truly between vertices, not starting and ending verts
inter_idx = int(tree_preds[to_idx])
while True:
Expand Down
3 changes: 1 addition & 2 deletions cityseer/util/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ def mock_data_dict(G: nx.Graph, length: int = 50, random_seed: int = None) -> di
for i in range(length):
data_dict[i] = {
'x': np.random.uniform(min_x, max_x),
'y': np.random.uniform(min_y, max_y),
'live': bool(np.random.randint(0, 1))
'y': np.random.uniform(min_y, max_y)
}

return data_dict
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The [`Network_Layer.compute_centrality`](/metrics/networks.html#compute-centrali
from cityseer.metrics import networks
# create a Network layer from the networkX graph
N = networks.Network_Layer_From_nX(G, distances=[200, 400, 800, 1600])
# the full underlying method allows the computation of various centralities simultaneously, e.g.
# the underlying method allows the computation of various centralities simultaneously, e.g.
N.compute_centrality(measures=['segment_harmonic', 'segment_betweenness'])
```

Expand Down
8 changes: 4 additions & 4 deletions docs/metrics/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ data_dict_WGS = mock.mock_data_dict(G_wgs, random_seed=25)
for i, (key, value) in enumerate(data_dict_WGS.items()):
print(key, value)
# prints:
# 0 {'x': -0.09600470559254023, 'y': 51.592916036617794, 'live': False}
# 1 {'x': -0.10621770551738155, 'y': 51.58888719412964, 'live': False}
# 0 {'x': -0.09600470559254023, 'y': 51.592916036617794}
# 1 {'x': -0.10621770551738155, 'y': 51.58888719412964}
if i == 1:
break

Expand All @@ -64,8 +64,8 @@ data_dict_UTM = layers.dict_wgs_to_utm(data_dict_WGS)
for i, (key, value) in enumerate(data_dict_UTM.items()):
print(key, value)
# prints:
# 0 {'x': 701144.5207785056, 'y': 5719758.706109629, 'live': False}
# 1 {'x': 700455.0000341447, 'y': 5719282.703221394, 'live': False}
# 0 {'x': 701144.5207785056, 'y': 5719758.706109629}
# 1 {'x': 700455.0000341447, 'y': 5719282.703221394}
if i == 1:
break
```
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy
numba
utm
shapely>=1.7a2
shapely>=1.7.0
networkx>=2.4
tqdm
matplotlib
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
python setup.py sdist bdist_wheel
pip install --upgrade twine
TESTING REPO: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
DOWNLOADING FROM TEST REPO: pip install --extra-index-url https://test.pypi.org/simple/ cityseer==0.10.2.dev0
DOWNLOADING FROM TEST REPO: pip install --extra-index-url https://test.pypi.org/simple/ cityseer==0.10.3.dev0
OTHERWISE: twine upload dist/*
'''

from setuptools import setup

setup(
name='cityseer',
version='0.10.2',
version='0.10.3.dev0',
packages=['cityseer', 'cityseer.algos', 'cityseer.metrics', 'cityseer.util'],
description='Computational tools for urban analysis',
url='https://github.com/cityseer/cityseer',
Expand Down
10 changes: 6 additions & 4 deletions tests/algos/test_centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,18 @@ def test_decomposed_local_centrality():
assert measures_data.shape == (m_range, d_range, len(G))
assert measures_data_decomposed.shape == (m_range, d_range, len(G_decomposed))
original_node_idx = np.where(node_data[:, 3] == 0)
# node based measures and betweenness segments will not match
# node measures can't filter by ghosted because then number of nodes is uneven
# segment betweenness become more finely spaced as the graph decomposes
# with increasing decomposition:
# - node based measures will not match
# - node based segment measures will match - these measure to the cut endpoints per thresholds
# - betweenness based segment won't match - doesn't measure to cut endpoints
for m_idx in range(m_range):
print(m_idx)
for d_idx in range(d_range):
match = np.allclose(measures_data[m_idx][d_idx], measures_data_decomposed[m_idx][d_idx][original_node_idx],
atol=0.1, rtol=0) # relax precision
if not match:
print('key', measure_keys[m_idx], 'dist:', distances[d_idx], 'match:', match)
if m_idx > 4 and m_idx != 10:
if m_idx in [5, 6, 7]:
assert match


Expand Down
1 change: 0 additions & 1 deletion tests/util/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def test_mock_data_dict():
# check that attributes are present
assert 'x' in v and isinstance(v['y'], (int, float))
assert 'y' in v and isinstance(v['y'], (int, float))
assert 'live' in v and isinstance(v['live'], bool)
assert v['x'] >= min_x and v['x'] <= max_x
assert v['y'] >= min_y and v['y'] <= max_y

Expand Down

0 comments on commit 537ef1a

Please sign in to comment.