diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index caa24e8..6309c78 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,9 +7,7 @@ on: branches: [main] jobs: - build: - name: ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -22,7 +20,6 @@ jobs: shell: bash -elo pipefail {0} steps: - - name: Checkout repo uses: actions/checkout@v3 with: diff --git a/.gitignore b/.gitignore index a03ff5b..790fda0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.vrt -keys.py +*.py notebooks/cache/* notebooks/data/* notebooks/logs/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb96a40..8e02da0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,10 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: "v4.4.0" hooks: - id: check-added-large-files args: [--maxkb=50] - - id: check-builtin-literals - id: check-case-conflict - - id: check-json - id: check-merge-conflict args: [--assume-in-merge] - id: check-yaml @@ -15,18 +13,32 @@ repos: - id: mixed-line-ending - id: no-commit-to-branch args: [--branch, main] - - id: requirements-txt-fixer - id: trailing-whitespace + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.0.0" + hooks: + - id: prettier + types_or: [markdown, yaml] + - repo: https://github.com/nbQA-dev/nbQA - rev: 1.7.0 + rev: "1.7.0" + hooks: + - id: nbqa-isort + additional_dependencies: [isort] + args: [--line-length=100, --sl] + - id: nbqa-black + additional_dependencies: [black] + args: [--line-length=100] + - id: nbqa-flake8 + additional_dependencies: [flake8] + args: [--max-line-length=100] + + - repo: local hooks: - - id: nbqa-isort - additional_dependencies: [isort] - args: [--line-length=100, --sl, --check-only] - - id: nbqa-black - additional_dependencies: [black] - args: [--line-length=100, --check] - - id: nbqa-flake8 - additional_dependencies: [flake8] - args: [--max-line-length=100] + - id: nbconvert + name: clear notebook output + entry: jupyter nbconvert + language: system + types: [jupyter] + args: ["--clear-output", "--inplace"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55d2e8f..916a44d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ Thanks for using OSMnx and for considering contributing to it! This issue tracke ## Contribute an example/demo - - post your proposal in the [issue tracker](https://github.com/gboeing/osmnx-examples/issues) or submit a PR with the new Jupyter notebook - - respond to code review +- post your proposal in the [issue tracker](https://github.com/gboeing/osmnx-examples/issues) or submit a PR with the new Jupyter notebook +- respond to code review Every piece of software is a work in progress. This project is the result of many hours of work contributed freely by myself and the many people that build the projects it depends on. Thank you for contributing! diff --git a/README.md b/README.md index d283e7b..b5eb06d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ This gallery contains step-by-step usage tutorials and feature demonstrations as Jupyter notebooks. You can run these notebooks interactively online with [Binder](https://mybinder.org/v2/gh/gboeing/osmnx-examples/main?urlpath=lab) or locally with the official OSMnx [Docker image](https://hub.docker.com/r/gboeing/osmnx). All of the examples are in this repo's [notebooks](notebooks) folder. Note that this repo's main branch generally tracks the functionality of the OSMnx repo's main branch. For examples corresponding to previously released versions of OSMnx, use this repo's tags to browse by release. ### More info: - - [Overview of OSMnx](https://geoffboeing.com/2016/11/osmnx-python-street-networks/) - - [OSMnx repo](https://github.com/gboeing/osmnx) - - [Documentation](https://osmnx.readthedocs.io/) - - [Journal article and citation info](https://geoffboeing.com/publications/osmnx-complex-street-networks/) + +- [Overview of OSMnx](https://geoffboeing.com/2016/11/osmnx-python-street-networks/) +- [OSMnx repo](https://github.com/gboeing/osmnx) +- [Documentation](https://osmnx.readthedocs.io/) +- [Journal article and citation info](https://geoffboeing.com/publications/osmnx-complex-street-networks/) diff --git a/notebooks/06-stats-indicators-centrality.ipynb b/notebooks/06-stats-indicators-centrality.ipynb index a911c44..6cef368 100644 --- a/notebooks/06-stats-indicators-centrality.ipynb +++ b/notebooks/06-stats-indicators-centrality.ipynb @@ -94,9 +94,9 @@ "# unpack dicts into individiual keys:values\n", "stats = ox.basic_stats(G, area=area)\n", "for k, count in stats[\"streets_per_node_counts\"].items():\n", - " stats[\"{}way_int_count\".format(k)] = count\n", + " stats[f\"{k}way_int_count\"] = count\n", "for k, proportion in stats[\"streets_per_node_proportions\"].items():\n", - " stats[\"{}way_int_prop\".format(k)] = proportion\n", + " stats[f\"{k}way_int_prop\"] = proportion\n", "\n", "# delete the no longer needed dict elements\n", "del stats[\"streets_per_node_counts\"]\n", diff --git a/notebooks/12-node-elevations-edge-grades.ipynb b/notebooks/12-node-elevations-edge-grades.ipynb index e67e02a..fa09e15 100644 --- a/notebooks/12-node-elevations-edge-grades.ipynb +++ b/notebooks/12-node-elevations-edge-grades.ipynb @@ -159,10 +159,10 @@ "outputs": [], "source": [ "avg_grade = np.mean(grades)\n", - "print(\"Average street grade in {} is {:.1f}%\".format(place, avg_grade * 100))\n", + "print(f\"Average street grade in {place} is {avg_grade * 100:.1f}%\")\n", "\n", "med_grade = np.median(grades)\n", - "print(\"Median street grade in {} is {:.1f}%\".format(place, med_grade * 100))" + "print(f\"Median street grade in {place} is {med_grade * 100:.1f}%\")" ] }, { @@ -304,7 +304,7 @@ " print(msg.format(np.sum(route_rises), ascent, abs(descent)))\n", "\n", " route_lengths = ox.utils_graph.route_to_gdf(G, route, weight=\"length\")[\"length\"]\n", - " print(\"Total trip distance: {:,.0f} meters\".format(np.sum(route_lengths)))" + " print(f\"Total trip distance: {np.sum(route_lengths):,.0f} meters\")" ] }, { diff --git a/tests/environment-tests.yml b/tests/environment-tests.yml index b9f9bc7..1c91a2c 100644 --- a/tests/environment-tests.yml +++ b/tests/environment-tests.yml @@ -2,11 +2,7 @@ name: osmnx-examples channels: - conda-forge dependencies: - - black - - flake8 - - isort - - jupyterlab - - nbqa + - jupyter - osmnx=1.5.1 - pillow - pre-commit diff --git a/tests/lint_format.sh b/tests/lint_format.sh deleted file mode 100644 index 5d5f4af..0000000 --- a/tests/lint_format.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -e -pre-commit run --all-files -jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace ./notebooks/*.ipynb