Skip to content

Commit

Permalink
Merge branch 'main' into feat_html_repr
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Rösner committed Sep 28, 2023
2 parents 79c8ff3 + 48f10d3 commit 55669d6
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
Expand Down
78 changes: 28 additions & 50 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy sdist and wheels
name: Build sdist and wheels
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
# https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent
concurrency:
Expand All @@ -17,10 +17,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create sdist
shell: bash -l {0}
# For non-tags/releases this won't produce a valid version number in the package
# We'd have to download the entire git history which is wasteful in CI
run: |
python -m pip install -q build
python -m build -s
Expand All @@ -33,69 +35,45 @@ jobs:


build_wheels:
name: "Build wheels on ${{ matrix.os }} ${{ matrix.cibw_archs }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11']
include:
# Using pythons inside a docker image to provide all the Linux
# python-versions permutations.
- name: manylinux 64-bit
os: ubuntu-latest
python-version: '3.11'
docker-image: manylinux2014_x86_64
- os: windows-2019
cibw_archs: "AMD64 ARM64"
- os: macos-11
cibw_archs: "x86_64 arm64"
- os: "ubuntu-20.04"
cibw_archs: "aarch64"
- os: "ubuntu-20.04"
cibw_archs: "x86_64"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
git fetch --prune --unshallow
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
python-version: '${{ matrix.python-version }}'
platforms: all

- name: Install dependencies
run: |
python -m pip install -U -q pip Cython wheel setuptools twine numpy build
- name: Build and install macOS/Windows wheel
if: matrix.os != 'ubuntu-latest'
run: |
python -m build -w
pip install --find-links=./dist/ pyresample
- name: Build Linux wheels inside docker
if: matrix.os == 'ubuntu-latest'
run: |
docker run \
-e PLAT=${{ matrix.docker-image }} \
-e USE_OMP=1 \
-v `pwd`:/io \
quay.io/pypa/${{ matrix.docker-image }} \
/io/continuous_integration/build-manylinux-wheels.sh
- name: Check version number from inside wheel
if: matrix.docker-image != 'manylinux2014_i686'
# install dependencies
# uninstall source installation
# move source to make sure it isn't include in checks
run: |
python -m pip install pip-tools
python -m piptools compile -o requirements.txt
mv pyresample unused_src_to_prevent_local_import
python -m pip install -r requirements.txt
python -m pip install --force-reinstall --no-index --no-cache-dir --no-deps --find-links=./dist/ pyresample
python -c "import pyresample; print(pyresample.__file__, pyresample.__version__)"
python -c "import pyresample; assert 'unknown' not in pyresample.__version__, 'incorrect version found'"
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.0
env:
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *i686 *-musllinux* cp312-*"
CIBW_ARCHS: "${{ matrix.cibw_archs }}"
CIBW_TEST_COMMAND: "python -c \"import pyresample; assert 'unknown' not in pyresample.__version__, 'incorrect version found'\""
CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"

- name: Upload wheel(s) as build artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
path: ./wheelhouse/*.whl

upload_test_pypi:
needs: [build_sdist, build_wheels]
Expand All @@ -115,7 +93,7 @@ jobs:
path: dist
- name: Publish package to PyPI
if: github.event.action != 'published'
uses: pypa/gh-action-pypi-publish@v1.8.7
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
Expand All @@ -137,7 +115,7 @@ jobs:
path: dist
- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.8.7
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^$'
fail_fast: false
repos:
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings, flake8-debugger, flake8-bugbear]
Expand Down
47 changes: 0 additions & 47 deletions continuous_integration/build-manylinux-wheels.sh

This file was deleted.

23 changes: 12 additions & 11 deletions continuous_integration/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ name: test-environment
channels:
- conda-forge
dependencies:
- xarray
- cartopy
- configobj
- Cython
- dask
- distributed
- donfig
- toolz
- Cython
- sphinx
- cartopy
- pillow
- matplotlib
- pillow
- platformdirs
- pyyaml
# 9.3.1 includes bug fix
- proj !=9.3.0
- pyproj
- pykdtree
- rasterio
- coveralls
- coverage
- codecov
- configobj
- zarr
- shapely
- scipy
- sphinx
- toolz
- xarray
- zarr
- coverage
- pytest
- pytest-cov
- pytest-lazy-fixture
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "oldest-supported-numpy", "Cython", "versioneer-518"]
requires = ["setuptools", "wheel", "numpy", "Cython", "versioneer-518"]
build-backend = "setuptools.build_meta"
13 changes: 10 additions & 3 deletions pyresample/_spatial_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@

import numpy as np
import pyproj
from pyproj import CRS
from pyproj.enums import TransformDirection

try:
import numexpr as ne
except ImportError:
ne = None

from ._multi_proc import Scheduler, shmem_as_ndarray
from .utils.proj4 import get_geodetic_crs_with_no_datum_shift

# Earth radius
R = 6370997.0
Expand Down Expand Up @@ -238,12 +241,16 @@ def _parallel_proj(scheduler, data1, data2, res1, res2, proj_args, proj_kwargs,
_res2 = shmem_as_ndarray(res2)

# Initialise pyproj
proj = pyproj.Proj(*proj_args, **proj_kwargs)
proj_def = proj_args[0] if proj_args else proj_kwargs
crs = CRS.from_user_input(proj_def)
gcrs = get_geodetic_crs_with_no_datum_shift(crs)
transformer = pyproj.Transformer.from_crs(gcrs, crs, always_xy=True)
trans_kwargs = {"radians": radians, "errcheck": errcheck,
"direction": TransformDirection.INVERSE if inverse else TransformDirection.FORWARD}

# Reproject data segment
for s in scheduler:
_res1[s], _res2[s] = proj(_data1[s], _data2[s], inverse=inverse,
radians=radians, errcheck=errcheck)
_res1[s], _res2[s] = transformer.transform(_data1[s], _data2[s], **trans_kwargs)

# An error occured, increment the return value ierr.
# Access to ierr is serialized by multiprocessing.
Expand Down
2 changes: 1 addition & 1 deletion pyresample/area_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _make_area(
"proj_id": proj_id,
}
attrs.update(kwargs)
area_def = AreaDefinition(projection, width, height, area_extent, attrs=attrs)
area_def = AreaDefinition(projection, (height, width), area_extent, attrs=attrs)
return area_def if pyresample.config.get("features.future_geometries", False) else area_def.to_legacy()

return DynamicAreaDefinition(area_id=area_id, description=description, projection=projection, width=width,
Expand Down
23 changes: 13 additions & 10 deletions pyresample/future/geometry/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class AreaDefinition(LegacyAreaDefinition):
crs:
Dictionary of PROJ parameters or string of PROJ or WKT parameters.
Can also be a :class:`pyproj.crs.CRS` object.
width:
x dimension in number of pixels, aka number of grid columns
height:
y dimension in number of pixels, aka number of grid rows
shape:
Shape of the geographic region. Currently only a 2-element tuple
is supported. The first element should be the number of elements
in the Y direction (rows) and the second in the X direction
(columns). So the final tuple is (rows, columns).
area_extent:
Area extent as a list (lower_left_x, lower_left_y, upper_right_x, upper_right_y)
attrs:
Expand All @@ -66,6 +67,8 @@ class AreaDefinition(LegacyAreaDefinition):
Identifier for the area. This is a convenience for backwards
compatibility and accesses the ``.attrs['name']`` metadata.
This will be set to an empty string if not provided.
shape:
Shape of the grid as (rows, columns).
width (int):
x dimension in number of pixels, aka number of grid columns
height (int):
Expand Down Expand Up @@ -101,25 +104,25 @@ class AreaDefinition(LegacyAreaDefinition):
def __init__(
self,
crs: Union[str, int, dict, CRS],
width: int,
height: int,
shape: tuple[int, ...],
area_extent: tuple[float, float, float, float],
attrs: Optional[dict] = None
):
# FUTURE: Maybe do `shape` instead of the separate height and width
# FUTURE: Add 'to_legacy()' method
# FUTURE: Add __slots__
# FUTURE: Convert this to new class that uses a legacy area internally
# Use this to more easily deprecate usage of old properties
if len(shape) != 2:
raise NotImplementedError("Only 2-dimensional areas are supported at this time.")

attrs = attrs or {}
area_id = attrs.get("name", "")
super().__init__(
area_id,
"",
area_id,
crs,
width,
height,
shape[1],
shape[0],
area_extent,
)
self.attrs = attrs
Expand Down
Loading

0 comments on commit 55669d6

Please sign in to comment.