Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into anvy-eval
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfleis committed Dec 5, 2024
2 parents 7495fe9 + a4b2bcc commit a6fed6e
Show file tree
Hide file tree
Showing 51 changed files with 25,327 additions and 318 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
50 changes: 13 additions & 37 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Continuous Integration

on:
push:
branches: [main]
Expand All @@ -17,15 +17,12 @@

jobs:
tests:
name: ${{ matrix.os }}, ${{ matrix.environment-file }}
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest]
environment-file: [
ci/py311_simplification-latest.yaml,
]
os: [ubuntu-latest, macos-latest, macos-14, windows-latest]
fail-fast: false

defaults:
Expand All @@ -37,41 +34,20 @@
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags.

- name: setup micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ matrix.environment-file }}
micromamba-version: "latest"

# - must be editable install for current tests to pass
# - due to data & pathing; probably need to:
# 1. rethink current 'convenience' funcs;
# 2. move `data/` into `core/data/`
# 3. something else
- name: install package
run: "pip install -e .[tests]"
- name: Setup Pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
cache: true
environments: "tests"

- name: environment info
run: "micromamba info && micromamba list"

- name: spatial versions
run: 'python -c "import geopandas; geopandas.show_versions();"'
run: 'pixi run -e tests python -c "import geopandas; geopandas.show_versions();"'

- name: run tests
run: |
pytest \
core/ \
--verbose \
-r a \
--numprocesses logical \
--color yes \
--cov core \
--cov-append \
--cov-report term-missing \
--cov-report xml . \
--env_type ${{ matrix.environment-file }}
run:
pixi run -e tests pytest -v -r a -n logical --color yes --cov code --cov-append --cov-report term-missing --cov-report xml .

- name: codecov
uses: codecov/codecov-action@v4
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@ cython_debug/
# Other stuff
.DS_Store
data/*/temp-parenx/*
*.qgz
*.qgz
# pixi environments
.pixi
*.egg-info
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ The curated & tested code base for the project & publication, including:
Parameterized notebooks.

* `/preprocessing/`: workflows used to preprocess [raw data](https://github.com/martinfleis/urban-block-artifacts) (clipping and removing degree 2 nodes)
* `/methods/`: exploration of different simplification methods, including the new method proposed here, `sgeop`
* `/methods/`: exploration of different simplification methods, including the new method proposed here, `neatnet`
* `/evaluation/`: comparative evaluation of each simplification method
* `/usecases/`: collection of use cases
* `/typology/`: exploration of different types of face artifacts, foundational to the `sgeop` algorithm
* `/typology/`: exploration of different types of face artifacts, foundational to the `neatnet` algorithm
* `/archive/`: archived notebooks

### `./data/`
Expand Down Expand Up @@ -88,11 +88,30 @@ Demonstration visualizations on specific types of urban form.
* `roandabout.mp4`
* `points.json` - use case locations

### `environment.yml`
### Reproducible environment

Install and activate the `conda` (or mamba) environment, which creates an environment name `simplification`:
This project uses reproducible multi-platform environments using [Pixi](https://pixi.sh). To create an environment able to run all the code in the repository, clone the repository and install the locked environment using:

```sh
pixi install
```
conda env create -f environment.yml
conda activate simplification

#### Development

To install the development environment allowing testing:

```sh
pixi install -e tests
```

If you would like to run the tests, use the `tests` Pixi environment:

```sh
pixi run -e tests pytest
```

Installing pre-commit hook to the env:

```sh
pixi run pre-commit install
```
41 changes: 0 additions & 41 deletions ci/py311_simplification-latest.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions core/algorithms/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import shapely
from esda import shape
from libpysal import graph
from scipy import sparse
from sgeop.geometry import (
from neatnet.geometry import (
_is_within,
snap_to_targets,
voronoi_skeleton,
)
from sgeop.nodes import weld_edges
from neatnet.nodes import weld_edges
from scipy import sparse

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions core/algorithms/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import numpy as np
import pandas as pd
from libpysal import graph
from scipy import sparse
from sgeop.continuity import continuity, get_stroke_info
from sgeop.nodes import (
from neatnet.continuity import continuity, get_stroke_info
from neatnet.nodes import (
_status,
consolidate_nodes,
fix_topology,
induce_nodes,
remove_false_nodes,
split,
)
from scipy import sparse

from .artifacts import (
get_artifacts,
Expand Down
2 changes: 1 addition & 1 deletion core/algorithms/triangles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import geopandas as gpd
import pandas as pd
import shapely
from sgeop.geometry import _is_within
from neatnet.geometry import _is_within
from tqdm.auto import tqdm


Expand Down
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.
10 changes: 5 additions & 5 deletions core/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_read_sample_data():
parenx_voronoi_records = [42_302, 9_569, 16_844, 29_446, 15_516, 14_242, 35_694]
parenx_skeletonize_records = [44_294, 9_561, 17_469, 30_641, 16_075, 14_784, 37_557]
osmnx_records = [43_451, 15_770, 24_025, 37_954, 21_755, 17_704, 30_156]
sgeop_records = [39_489, 8_229, 13_587, 29_028, 12_395, 11_059, 16_298]
neatnet_records = [39_489, 8_229, 13_587, 29_028, 12_395, 11_059, 16_298]


@pytest.mark.parametrize("city, n_records", zip(cities, osm_records, strict=True))
Expand Down Expand Up @@ -123,12 +123,12 @@ def test_read_parenx_skeletonize(city, n_records):
assert gdf_1.crs == gdf_2.crs == pytest.epsg_4326


@pytest.mark.parametrize("city, n_records", zip(cities, sgeop_records, strict=True))
def test_read_sgeop(city, n_records):
@pytest.mark.parametrize("city, n_records", zip(cities, neatnet_records, strict=True))
def test_read_neatnet(city, n_records):
fua = core.utils.city_fua[city]

gdf_1 = core.utils.read_sgeop(fua, pytest.epsg_4326)
gdf_2 = core.utils.read_sgeop(core.utils.fua_city[fua], pytest.epsg_4326)
gdf_1 = core.utils.read_neatnet(fua, pytest.epsg_4326)
gdf_2 = core.utils.read_neatnet(core.utils.fua_city[fua], pytest.epsg_4326)

geopandas.testing.assert_geodataframe_equal(gdf_1, gdf_2)

Expand Down
13 changes: 0 additions & 13 deletions core/tests/test_viz_h3_hex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from matplotlib.testing.decorators import image_comparison
from matplotlib.testing.exceptions import ImageComparisonFailure

import core

Expand All @@ -14,10 +13,6 @@ 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 Expand Up @@ -60,10 +55,6 @@ def setup_method(
self._m = "manual"
self._p = "parenx-voronoi"

@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=ImageComparisonFailure,
)
@image_comparison(
baseline_images=["test_viz_h3_hex_plot_cell_loc_id.png"], style="mpl20", tol=tol
)
Expand All @@ -79,10 +70,6 @@ def test_loc_id(self):
self._p,
)

@pytest.mark.xfail(
reason="Needs updated Manual & Parenx -- See GH#131.",
raises=ImageComparisonFailure,
)
@image_comparison(
baseline_images=["test_viz_h3_hex_plot_cell_hex_id.png"],
style="mpl20",
Expand Down
8 changes: 4 additions & 4 deletions core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"read_cityseer",
"read_osmnx",
"read_parenx",
"read_sgeop",
"read_neatnet",
"graph_size",
"load_usecases",
"make_grid",
Expand Down Expand Up @@ -128,11 +128,11 @@ def read_parenx(
)


def read_sgeop(fua: int, proj_crs: str | int | pyproj.CRS) -> geopandas.GeoDataFrame:
"""Read in prepared sgeop data."""
def read_neatnet(fua: int, proj_crs: str | int | pyproj.CRS) -> geopandas.GeoDataFrame:
"""Read in prepared neatnet data."""

return (
geopandas.read_parquet(_fua_path(fua, "sgeop"))
geopandas.read_parquet(_fua_path(fua, "neatnet"))
.explode(ignore_index=True, index_parts=False)
.to_crs(proj_crs)
)
Expand Down
Binary file modified data/1133/cityseer/1133.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/1133/osmnx/1133.parquet
Binary file not shown.
Binary file modified data/1656/cityseer/1656.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/1656/osmnx/1656.parquet
Binary file not shown.
Binary file modified data/4617/cityseer/4617.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/4617/osmnx/4617.parquet
Binary file not shown.
Binary file modified data/4881/cityseer/4881.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/4881/osmnx/4881.parquet
Binary file not shown.
Binary file modified data/809/cityseer/809.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/809/osmnx/809.parquet
Binary file not shown.
Binary file modified data/869/cityseer/869.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/869/osmnx/869.parquet
Binary file not shown.
Binary file modified data/8989/cityseer/8989.parquet
Binary file not shown.
File renamed without changes.
Binary file modified data/8989/osmnx/8989.parquet
Binary file not shown.
41 changes: 0 additions & 41 deletions environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion notebooks/archive/evaluate_h3cells_2024-12-02.ipynb

Large diffs are not rendered by default.

File renamed without changes.
8 changes: 4 additions & 4 deletions notebooks/archive/simplification_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"import warnings\n",
"\n",
"import folium\n",
"import sgeop\n",
"import neatnet\n",
"\n",
"from core import utils"
]
Expand Down Expand Up @@ -57,8 +57,8 @@
"metadata": {},
"outputs": [],
"source": [
"# # Get the logger for sgeop.simplify\n",
"# logger = logging.getLogger('sgeop.simplify')\n",
"# # Get the logger for neatnet.simplify\n",
"# logger = logging.getLogger('neatnet.simplify')\n",
"# logger.setLevel(logging.DEBUG)\n",
"\n",
"# # Set the logging format\n",
Expand Down Expand Up @@ -118,7 +118,7 @@
"metadata": {},
"outputs": [],
"source": [
"new_roads = sgeop.simplify_network(roads)"
"new_roads = neatnet.simplify_network(roads)"
]
},
{
Expand Down
Loading

0 comments on commit a6fed6e

Please sign in to comment.