Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into pointcloud_class
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Nov 29, 2024
2 parents 29c3e1b + 04b170a commit 0a1a9f5
Show file tree
Hide file tree
Showing 114 changed files with 10,204 additions and 4,761 deletions.
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

- [ ] Resolves #xxx,
- [ ] Tests added, otherwise issue #xxx opened,
- [ ] New optional dependencies added to both `dev-environment.yml` and `setup.cfg`,
- [ ] Fully documented, including `api/*.md` for new API.
- [ ] New optional dependencies or Python version support added to both `dev-environment.yml` and `setup.cfg`,
- [ ] If contributor workflow (test, doc, linting) or Python version support changed, update `CONTRIBUTING.md`.
23 changes: 9 additions & 14 deletions .github/scripts/generate_pip_deps_from_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@

EXCLUDE = {"python"}
REMAP_VERSION = {"tzdata": "2022.1"}
RENAME = {
"pytables": "tables",
"psycopg2": "psycopg2-binary",
"dask-core": "dask",
"seaborn-base": "seaborn",
"sqlalchemy": "SQLAlchemy",
}
RENAME = {}


def conda_package_to_pip(package: str):
Expand Down Expand Up @@ -108,13 +102,14 @@ def generate_pip_from_conda(conda_path: pathlib.Path, pip_path: pathlib.Path, co
)
pip_content = header + "\n".join(pip_deps) + "\n"

# add setuptools to requirements-dev.txt
with open(pathlib.Path(conda_path.parent, "pyproject.toml"), "rb") as fd:
meta = tomllib.load(fd)
for requirement in meta["build-system"]["requires"]:
if "setuptools" in requirement:
pip_content += requirement
pip_content += "\n"
# Add setuptools to requirements-dev.txt

# with open(pathlib.Path(conda_path.parent, "pyproject.toml"), "rb") as fd:
# meta = tomllib.load(fd)
# for requirement in meta["build-system"]["requires"]:
# if "setuptools" in requirement:
# pip_content += requirement
# pip_content += "\n"

if compare:
with pip_path.open() as file:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/pip-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This workflow checks that pip installation works to import the package (tests are in python-tests.yml)

name: pip-install

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
name: ${{ matrix.os }}, python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11", "3.12"]

# Run all shells using bash (including Windows)
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v4

# We initiate the environment empty
- name: Initiate empty environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-update-conda: true
use-mamba: true
channel-priority: strict
activate-environment: geoutils-pip
python-version: ${{ matrix.python-version }}

# Use pip install
- name: Install project
run: |
mamba install pip
pip install -e .
# Check import works
- name: Check import works with base environment
run: python -c "import geoutils"
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:

strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.10", "3.11", "3.12"]

defaults:
run:
Expand All @@ -30,7 +30,6 @@ jobs:
- name: Initiate empty environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
auto-update-conda: true
use-mamba: true
Expand Down Expand Up @@ -88,7 +87,12 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Setup pip dependencies
run: pip install pytest-cov coveralls coveragepy-lcov
run: pip install pytest-cov coveralls coveragepy-lcov 'coverage<7'

- name: Print conda environment (for debugging)
run: |
conda info
conda list
- name: Test with pytest
run: pytest -ra --cov=geoutils/
Expand Down
33 changes: 19 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -12,10 +12,14 @@ repos:
- id: check-merge-conflict
# Fix common spelling mistakes
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.3.0
hooks:
- id: codespell
args: [--ignore-words-list=alos, --ignore-regex=\bnin\b]
args: [
'--ignore-words-list', 'alos,inout,vor',
'--ignore-regex', '\bnin\b',
'--'
]
types_or: [python, rst, markdown]
files: ^(geoutils|doc|tests)/

Expand All @@ -27,23 +31,24 @@ repos:

# Format the code aggressively using black
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 24.10.0
hooks:
- id: black
args: [--line-length=120]

# Lint the code using flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
rev: 7.1.1
hooks:
- id: flake8
args: [
--max-line-length=120,
--extend-ignore=E203, # flake8 disagrees with black, so this should be ignored.
'--max-line-length', '120', # we can write dicts however we want
'--extend-ignore', 'E203,B028', # flake8 disagrees with black, so this should be ignored.
'--'
]
additional_dependencies:
- flake8-comprehensions==3.1.0
- flake8-bugbear==21.3.2
- flake8-comprehensions
- flake8-bugbear
files: ^(geoutils|tests)
# Lint the code using mypy
- repo: https://github.com/pre-commit/mirrors-mypy
Expand All @@ -63,26 +68,26 @@ repos:
--disable-error-code=var-annotated,
--disable-error-code=no-any-return
]
additional_dependencies: [tokenize-rt==3.2.0, numpy==1.22]
additional_dependencies: [tokenize-rt==3.2.0, numpy==1.26]
files: ^(geoutils|tests)

# Sort imports using isort
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [ "--profile", "black" ]

# Automatically upgrade syntax to a minimum version
- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: [--py37-plus]

# Various formattings
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
# Single backticks should apparently not be used
- id: rst-backticks
Expand All @@ -101,7 +106,7 @@ repos:

# Add custom regex lints (see .relint.yml)
- repo: https://github.com/codingjoe/relint
rev: 2.0.0
rev: 3.3.1
hooks:
- id: relint
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For more details, see the rest of this document.

## Development environment

GeoUtils currently supports only Python versions of 3.9 and higher, see `environment.yml` for detailed dependencies.
GeoUtils currently supports only Python versions of 3.10 to 3.12, see `environment.yml` for detailed dependencies.

### Setup

Expand Down
8 changes: 6 additions & 2 deletions bin/geoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ def main(test_args: Sequence[str] = None) -> None:
vmax = None

# color map
# Get the list of existing color maps, including reversed maps
mpl_cmap_list = list(plt.cm.datad.keys())
mpl_cmap_list.extend([cmap + "_r" for cmap in mpl_cmap_list])

if args.cmap == "default":
cmap = plt.rcParams["image.cmap"]
elif args.cmap in plt.cm.datad.keys():
elif args.cmap in mpl_cmap_list:
cmap = args.cmap
else:
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in plt.cm.datad.keys())))
raise ValueError("Wrong cmap, must be in: {}".format(",".join(str(elem) for elem in mpl_cmap_list)))

# Figsize
if args.figsize == "default":
Expand Down
11 changes: 8 additions & 3 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: geoutils-dev
channels:
- conda-forge
dependencies:
- python>=3.9,<3.12
- geopandas>=0.12.0,<0.14
- python>=3.10,<3.13
- geopandas>=0.12.0
- matplotlib=3.*
- pyproj=3.*
- rasterio>=1.3,<2
- pandas>=1,<2.2
- pandas>=1,<3
- numpy=1.*
- scipy=1.*
- tqdm
- xarray
- dask
- rioxarray=0.*
- python-pdal

Expand All @@ -22,12 +23,16 @@ dependencies:
- scikit-image

# Test dependencies
- gdal # To test functionalities against GDAL
- pytest=7.*
- pytest-xdist
- pytest-lazy-fixture
- pyyaml
- flake8
- pylint
- netcdf4 # To write synthetic data with chunksizes
- dask-memusage
- pre-commit

# Doc dependencies
- sphinx
Expand Down
8 changes: 8 additions & 0 deletions doc/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* Work around to wrong dark-mode for toggle button: https://github.com/executablebooks/MyST-NB/issues/523 */
div.cell details.hide > summary {
background-color: var(--pst-color-surface);
}

div.cell details[open].above-input div.cell_input {
border-top: None;
}
10 changes: 5 additions & 5 deletions doc/source/about_geoutils.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In particular, GeoUtils:
- Strives to rely on **lazy operations** under-the-hood to avoid unnecessary data loading,
- Allows for **match-reference operations** to facilitate geospatial handling,
- Re-implements **several of [GDAL](https://gdal.org/)'s features** missing in other packages (e.g., proximity, gdalDEM),
- Naturally handles **different `dtypes` and `nodata`** values through its NumPy masked-array interface.
- Naturally handles **different `dtype` and `nodata`** values through its NumPy masked-array interface.


```{note}
Expand Down Expand Up @@ -90,13 +90,13 @@ header-rows: 1
* - ```{eval-rst}
.. literalinclude:: code/about_geoutils_sidebyside_raster_geoutils.py
:language: python
:lines: 12-29
:lines: 15-30
```
- ```{eval-rst}
.. literalinclude:: code/about_geoutils_sidebyside_raster_rasterio.py
:language: python
:lines: 10-62
:lines: 11-57
```
`````

Expand All @@ -112,13 +112,13 @@ header-rows: 1
* - ```{eval-rst}
.. literalinclude:: code/about_geoutils_sidebyside_vector_geoutils.py
:language: python
:lines: 10-25
:lines: 11-26
```
- ```{eval-rst}
.. literalinclude:: code/about_geoutils_sidebyside_vector_geopandas.py
:language: python
:lines: 10-40
:lines: 11-34
```
`````
Loading

0 comments on commit 0a1a9f5

Please sign in to comment.