Skip to content

Commit

Permalink
chore: bump deps, switch to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
carderne committed Feb 16, 2024
1 parent 1db3a86 commit f4dcd99
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 202 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Build
run: |
pip install build
python -m build
- name: Publish
# mimics: twine upload dist/* --skip-existing
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
10 changes: 0 additions & 10 deletions .readthedocs.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

30 changes: 5 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,10 @@ gridfinder requires the following data sources:

## Model usage

To get to grips with the API and steps in the model, open the Jupyter notebook `example.ipynb`. This repository includes the input data needed to do a test run for Burundi, so it should be a matter of openening the notebook and running all cells.
To get to grips with the API and steps in the model, open the Jupyter notebook `example.ipynb`.
This repository includes the input data needed to do a test run for Burundi, so it should be a matter of openening the notebook and running all cells.

## Installation
### Requirements
gridfinder requires Python >= 3.5 with the following packages installed:
- `numpy` >=1.2.0
- `scikit-image` >=0.14.1
- `rasterio` >=1.0.13
- `geopandas` >=0.4.0

These additional packages may be necessary depending on your configuration:
- `Rtree` >= 0.8.3
- `affine` >= 2.2.1
- `Pillow` >= 5.3.0
- `pyproj` >= 1.9.5.1
- `pytz` >= 2018.7
- `descartes`

And these for using an interactive notebook:
- `IPython`
- `jupyter`
- `matplotlib`
- `seaborn`
- `folium`

### Install with pip

pip install gridfinder
Expand All @@ -51,6 +30,7 @@ Download or clone the repository and install the required packages (preferably i

git clone https://github.com/carderne/gridfinder.git
cd gridfinder
pip install -r requirements.txt
pip install -e '.[dev]'

You can run ```./test.sh``` in the directory, which will do an entire run through using the test data and confirm whether everything is set up properly. (It will fail if jupyter isn't installed!)
You can run ```./test.sh``` in the directory, which will do an entire run through using the test data and confirm whether everything is set up properly.
(It will fail if jupyter isn't installed!)
16 changes: 6 additions & 10 deletions example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"raster_merged, affine = gf.merge_rasters(folder_ntl_out, percentile=percentile)\n",
Expand Down Expand Up @@ -131,7 +129,7 @@
"\n",
"fig = plt.figure()\n",
"sns.set()\n",
"ax = fig.gca(projection='3d')\n",
"ax = fig.add_subplot(projection='3d')\n",
"ax.plot_surface(X, Y, ntl_filter, cmap=cm.coolwarm, linewidth=0, antialiased=False)"
]
},
Expand Down Expand Up @@ -297,9 +295,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"guess_gdf = gf.raster_to_lines(guess_skeletonized_out)\n",
Expand Down Expand Up @@ -332,7 +328,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -346,9 +342,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.12.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
99 changes: 14 additions & 85 deletions example_simple.ipynb

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions gridfinder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
"""
gridfinder package contains the following modules:
- _util.py : helper functions used internally
- gridfinder.py : main implementation of Dijkstra's algorithm
- prepare.py : transforming input data into the cost and targets arrays
- post.py : postprocess the algorithm output and check accuracy
- _util.py : helper functions used internally
- prepare.py : transforming input data into the cost and targets arrays
"""

__version__ = "1.1.1"
from importlib.metadata import version

from ._util import * # NoQA
from .gridfinder import * # NoQA
from .post import * # NoQA
from .prepare import * # NoQA

from .prepare import *
from .gridfinder import *
from .post import *
from ._util import *
__version__ = version("gridfinder")
99 changes: 99 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[build-system]
requires = [
"setuptools>=65",
"wheel>=0.37.1",
"setuptools-scm[toml]>=7.0.5",
]
build-backend = "setuptools.build_meta"

[project]
name = "gridfinder"
description = "Algorithm for guessing MV grid network based on night time lights"
readme = "README.md"
license = {text = "MIT License"}
requires-python = ">=3.8"
keywords = ["ntl", "electricity", "grid"]

authors = [
{name = "Chris Arderne", email="[email protected]"},
]

dynamic = ["version"]

classifiers = [
"Environment :: Console",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
]

dependencies = [
"affine ~= 2.4",
"click ~= 8.0",
"fiona ~= 1.9",
"geopandas ~= 0.14",
"numpy ~= 1.26",
"pandas ~= 2.2",
"pillow ~= 10.2",
"pyproj ~= 3.6",
"rasterio ~= 1.3",
"Rtree ~= 1.2",
"scikit-image ~= 0.22",
"scipy ~= 1.12",
"Shapely ~= 2.0",
]

[project.optional-dependencies]
dev = [
"branca ~= 0.7",
"descartes ~= 1.1.0",
"folium ~= 0.15",
"matplotlib ~= 3.8",
"seaborn ~= 0.13",
]

[project.urls]
homepage = "https://gridfinder.rdrn.me"
repository = "https://github.com/carderne/gridfinder"

[tool.setuptools]
packages = ["gridfinder"]

[tool.setuptools_scm]

[tool.black]
line-length = 88

[tool.ruff]
target-version = "py38"
exclude = []

[tool.ruff.lint]
select = [
"F",
"E",
"I",
"U",
"N",
"E",
"S",
"T100",
"A",
"Q",
"ANN",
]

[tool.ruff.lint.isort]
known-first-party = ["gridfinder"]

[tool.mypy]
show_error_codes = true
show_error_context = true
show_traceback = true
disallow_untyped_defs = true
disallow_any_unimported = true
no_implicit_optional = true
check_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
warn_unreachable = true
21 changes: 0 additions & 21 deletions requirements.txt

This file was deleted.

26 changes: 0 additions & 26 deletions setup.py

This file was deleted.

0 comments on commit f4dcd99

Please sign in to comment.