Skip to content

Commit

Permalink
Add pre-commit (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
g4brielvs committed Feb 26, 2024
1 parent 5e13132 commit 707a059
Show file tree
Hide file tree
Showing 48 changed files with 4,556 additions and 2,441 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/blackmarblepy
url: https://pypi.org/p/GOSTurban
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ dmypy.json
.pyre/

# Project-specific
_build/
_build/
docs/api/
src/GOSTurban/_version.py
src/GOSTurban/_version.py
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
name: Markdownlint
files: \.(md|mdown|markdown)$
args: [
"--disable=MD013", # line-length
"--disable=MD033", # no-inline-html
]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,42 @@ This repo includes a [GitHub Pages](https://worldbank.github.io/GOSTurban/README

### From PyPI

**GOSTurban** is available on [PyPI](https://pypi.org) and can installed using `pip`:
**GOSTurban** is available on [PyPI](https://pypi.org/project/GOSTurban/) and can installed using `pip`:

```shell
pip install GOSTurban
```

### From Source

1. Clone or download this repository to your local machine. Then, navigate to the root directory of the repository:

```shell
git clone https://github.com/worldbank/GOSTurban.git
cd GOSTurbang
```

2. Create a virtual environment (optional but recommended):

```shell
python3 -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
```

3. Install the package with dependencies:

```shell
pip install .
```

Install the package **in editable** mode with dependencies:

```shell
pip install -e .
```

The `-e` flag stands for "editable," meaning changes to the source code will immediately affect the installed package.

## License

This project is licensed under the [**MIT**](https://opensource.org/license/mit) - see the [LICENSE](LICENSE) file for details.
2 changes: 1 addition & 1 deletion build_commands.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Commit to github
git status
git status
git add -A
git commit -m "FUBAR"
git push
Expand Down
10 changes: 5 additions & 5 deletions docs/novel_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

The European Commission developed a globally consistent, people-centric definition of urban areas. The basic approach is to apply a threshold to population grids on both the minimum population density, and then on the minimum total population of the resulting settlements. While the team at the EC continues to advance and iterate on their methodology, we rely on the original definitions of urban they produced:

| Urban area | Min Pop Density | Min Settlement Pop |
| Urban area | Min Pop Density | Min Settlement Pop |
| --- | --- | --- |
| Urban areas | 300 people/km2 | 5000 people |
| High density urban areas | 1500 people/km2 | 50000 people |
| Urban areas | 300 people/km2 | 5000 people |
| High density urban areas | 1500 people/km2 | 50000 people |

## [Bellefon (2021)](https://www.sciencedirect.com/science/article/pii/S0094119019301032)

Expand All @@ -21,6 +21,6 @@ This method eschews the absolute density thresholds of the EC methodology and in

| Urban area | Definition |
| --- | --- |
| Urban areas | contiguous pixels for which the density is above the 95th percentile of the counterfactual |
| Urban areas | contiguous pixels for which the density is above the 95th percentile of the counterfactual |
| Cores | contiguous pixels within urban areas that are above the 95th percentile of the counterfactual within the urban core |
| Cities | urban areas that have a core |
| Cities | urban areas that have a core |
10 changes: 5 additions & 5 deletions docs/urbanization_comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ Map comparison is a complicated process, as there are many tools and approaches.

## Degree of Urbanization

| Urban area | Min Pop Density | Min Settlement Pop |
| Urban area | Min Pop Density | Min Settlement Pop |
| --- | --- | --- |
| Urban areas | 300 people/km2 | 5000 people |
| High density urban areas | 1500 people/km2 | 50000 people |
| Urban areas | 300 people/km2 | 5000 people |
| High density urban areas | 1500 people/km2 | 50000 people |

## Dartboard

| Urban area | Definition |
| --- | --- |
| Urban areas | contiguous pixels for which the density is above the 95th percentile of the counterfactual |
| Urban areas | contiguous pixels for which the density is above the 95th percentile of the counterfactual |
| Cores | contiguous pixels within urban areas that are above the 95th percentile of the counterfactual within the urban core |
| Cities | urban areas that have a core |
| Cities | urban areas that have a core |

Any attempt to compare these methods has to start with a question of what do we compare: the DoU method produces two layers, and the DB method produces three. After investigating the data it is clear that the DoU urban area is equivalent to the DB urban areas. However, the comparison of the DoU high density to the DB could be to either the Cores or the cities. In the figures below you can see the comparison to both, however, let's look at the nature of the comparison:

Expand Down
Loading

0 comments on commit 707a059

Please sign in to comment.