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

deleted service roads #161

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 1 addition & 10 deletions core/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import pytest
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.exceptions import ImageComparisonFailure

import core

Expand All @@ -11,13 +10,9 @@

@pytest.mark.parametrize(
"protocol_type, remove_false_nodes, known_lines, known_verts",
zip(protocol_types, [True, False], [25, 16], [14, 8], strict=True),
zip(protocol_types, [True, False], [17, 8], [9, 3], strict=True),
ids=protocol_types,
)
@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=AssertionError,
)
def test_generate_case(protocol_type, remove_false_nodes, known_lines, known_verts):
_case = core.protocol.protocol_cases["04"]

Expand Down Expand Up @@ -61,10 +56,6 @@ def test_process_case_invalid_type():
)


@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=ImageComparisonFailure,
)
@image_comparison(
baseline_images=["test_process_case_original.png"],
style="mpl20",
Expand Down
8 changes: 4 additions & 4 deletions core/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def test_add_node_degree(manual_auckland):
observed = core.stats.add_node_degree(nodes_manual, manual_graph)["degree"]

assert isinstance(observed, pandas.Series)
assert observed.shape[0] == 31050
assert observed.sum() == 71300
assert observed.shape[0] == 6755
assert observed.sum() == 17280


def test_get_edge_stats(manual_auckland, grid_9_auckland):
_, _, edges_manual = manual_auckland
grid_cell = grid_9_auckland[grid_9_auckland["hex_id"] == "89bb50031c7ffff"].geometry

known_count, known_length = (5, 578.75495776233)
known_count, known_length = (5, 551.6152216584356)
observed_count, observed_length = core.stats.get_edge_stats(edges_manual, grid_cell)

assert observed_count == known_count
Expand All @@ -34,7 +34,7 @@ def test_get_node_stats(manual_auckland, grid_9_auckland):
manual_graph, nodes_manual, _ = manual_auckland
grid_cell = grid_9_auckland[grid_9_auckland["hex_id"] == "89bb50031c7ffff"].geometry

known_count, known_distr, known_avg = (3, {1: 2, 3: 1}, 1.6666666666666667)
known_count, known_distr, known_avg = (4, {1: 3, 3: 1}, 1.5)
observed_count, observed_distr, observed_avg = core.stats.get_node_stats(
core.stats.add_node_degree(nodes_manual, manual_graph), grid_cell
)
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_read_sample_data():
cities = list(core.utils.city_fua.keys())
osm_records = [78_908, 60_364, 79_317, 84_819, 79_907, 50_917, 92_667]
xnd2_records = [43_233, 12_439, 16_302, 30_552, 16_554, 13_468, 29_314]
man_records = [41_481, 35_650, 20_347, 30_647, 25_133, 43_955, numpy.nan]
man_records = [38_772, 8_640, 14_170, 29_252, 13_508, 11_032, numpy.nan]


@pytest.mark.parametrize("city, n_records", zip(cities, osm_records, strict=True))
Expand Down
8 changes: 4 additions & 4 deletions core/tests/test_viz_h3_hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import core


@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=ImageComparisonFailure,
)
@image_comparison(
baseline_images=["test_viz_h3_hex_plot_aoi.png"],
style="mpl20",
Expand All @@ -18,6 +14,10 @@ def test_viz_h3_hex_plot_aoi(grid_8_auckland):
core.viz.h3_hex.plot_aoi(grid_8_auckland, "Auckland", 8)


@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=ImageComparisonFailure,
)
@image_comparison(
baseline_images=["test_viz_h3_hex_plot_analysis.png"],
style="mpl20",
Expand Down
Binary file modified data/1133/manual/1133.parquet
Binary file not shown.
Binary file modified data/1656/manual/1656.parquet
Binary file not shown.
Binary file modified data/4617/manual/4617.parquet
Binary file not shown.
Binary file modified data/4881/manual/4881.parquet
Binary file not shown.
Binary file modified data/809/manual/809.parquet
Binary file not shown.
Binary file modified data/869/manual/869.parquet
Binary file not shown.
113 changes: 113 additions & 0 deletions notebooks/check_corrected_input_data.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "57d0ba47-4d99-493d-ae34-d5146ed77e01",
"metadata": {},
"source": [
"# Check the correct manual road network data\n",
"## (purged service roads)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c785905e-e1de-4940-9a40-d50a1769062a",
"metadata": {},
"outputs": [],
"source": [
"%config InlineBackend.figure_format = \"retina\"\n",
"%load_ext watermark\n",
"%watermark"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b4891b2f-c26f-450e-8afb-ce147455d649",
"metadata": {},
"outputs": [],
"source": [
"import pathlib\n",
"\n",
"import matplotlib.pyplot\n",
"\n",
"import core # noqa: F401\n",
"from core import utils"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a124677d-de91-4164-9f9b-fa07afe1904d",
"metadata": {},
"outputs": [],
"source": [
"%watermark -w\n",
"%watermark -iv"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ec07872-0a18-400b-98cf-2c2a05c59727",
"metadata": {},
"outputs": [],
"source": [
"utils.fua_city"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "404136d3-2375-442f-8d8b-b97148502f8a",
"metadata": {},
"outputs": [],
"source": [
"for fua, city in utils.fua_city.items():\n",
" print(\n",
" \"================================\\n\"\n",
" f\"* {city} *\"\n",
" \"\\n--------------\"\n",
" )\n",
" if city == \"Wuhan\":\n",
" continue\n",
" o = utils.read_original(city)\n",
" m = utils.read_manual(city, o.crs)\n",
"\n",
" print(\n",
" \"Records\\n\"\n",
" f\" Orig: {o.shape[0]:,}\\n\"\n",
" f\" Manu: {m.shape[0]:,}\\n\"\n",
" )\n",
"\n",
" b = o.plot(figsize=(20,20), ec=\"k\", lw=.5, alpha=.5, zorder=1)\n",
" m.plot(ax=b, ec=\"b\", lw=.2, alpha=1, zorder=2)\n",
"\n",
" # large plot\n",
" matplotlib.pyplot.savefig(f\"{city}_orig_vs_manu.png\", dpi=400)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading