Skip to content

Commit

Permalink
DEP: Support Python 3.10-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Dec 22, 2023
1 parent 9dfe2f4 commit 047851d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
- name: Setup Conda
uses: s-weigand/setup-conda@v1
with:
python-version: 3.9
python-version: 3.10
conda-channels: conda-forge

- name: Install and Build
shell: bash
run: |
conda config --prepend channels conda-forge
conda config --set channel_priority strict
conda create -n docs python=3.9 rasterio xarray scipy pyproj pandoc
conda create -n docs python=3.10 rasterio xarray scipy pyproj pandoc
source activate docs
python -m pip install -e .[doc]
sphinx-build -b html docs/ docs/_build/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'

- name: Install dependencies
run: |
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
rasterio-version: ['']
xarray-version: ['']
pandas-version: ['']
run-with-scipy: ['YES']
gdal-version: ['3.6.4']
include:
- python-version: '3.9'
- python-version: '3.10'
rasterio-version: ''
xarray-version: '==0.17'
pandas-version: '<2'
run-with-scipy: 'YES'
gdal-version: '3.4.3'
- python-version: '3.9'
- python-version: '3.10'
rasterio-version: '==1.2.1'
xarray-version: ''
pandas-version: ''
run-with-scipy: 'YES'
gdal-version: '3.5.3'
- python-version: '3.9'
- python-version: '3.10'
rasterio-version: ''
xarray-version: ''
pandas-version: ''
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
rasterio-version: ['*']
xarray-version: ['*']
run-with-scipy: ['YES']
Expand Down Expand Up @@ -142,15 +142,15 @@ jobs:
conda info
- name: pylint
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.10'
shell: bash
run: |
source activate test
pylint rioxarray/
- name: mypy
shell: bash
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.10'
run: |
source activate test
mypy rioxarray/
Expand Down Expand Up @@ -181,15 +181,15 @@ jobs:
- name: Setup Conda
uses: s-weigand/setup-conda@v1
with:
python-version: 3.9
python-version: 3.10
conda-channels: conda-forge

- name: Install Env
shell: bash
run: |
conda config --prepend channels conda-forge
conda config --set channel_priority strict
conda create -n test python=3.9 proj libgdal cython netcdf4
conda create -n test python=3.10 proj libgdal cython netcdf4
source activate test
python -m pip install \
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.9-3.11.
3. The pull request should work for Python 3.10-3.12.

Tips
----
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG GDAL=ubuntu-full-3.6.4
FROM ghcr.io/osgeo/gdal:${GDAL}
ARG PYTHON_VERSION="3.9"
ARG PYTHON_VERSION="3.10"
ENV LANG="C.UTF-8"
ENV LC_ALL="C.UTF-8"
ENV PIP_NO_BINARY="rasterio"
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

environment:
matrix:
- PYTHON_VERSION: "3.9"
- PYTHON_VERSION: "3.10"
MINICONDA: "C:\\Miniconda3-x64"

install:
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.9
python_version = 3.10

[mypy-affine]
ignore_missing_imports = True
Expand Down
54 changes: 28 additions & 26 deletions rioxarray/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ def __init__(
self.mask_and_scale = mask_and_scale

# cannot save riods as an attribute: this would break pickleability
riods = _ensure_warped_vrt(manager.acquire(), vrt_params)
self.vrt_params = vrt_params
self._shape = (riods.count, riods.height, riods.width)

self._dtype = None
self._unsigned_dtype = None
self._fill_value = riods.nodata
dtypes = riods.dtypes
with _ensure_warped_vrt(manager.acquire(), vrt_params) as riods:
self.vrt_params = vrt_params
self._shape = (riods.count, riods.height, riods.width)

self._dtype = None
self._unsigned_dtype = None
self._fill_value = riods.nodata
dtypes = riods.dtypes
if not numpy.all(numpy.asarray(dtypes) == dtypes[0]):
raise ValueError("All bands should have the same dtype")

Expand Down Expand Up @@ -424,26 +424,28 @@ def _getitem(self, key):
out = numpy.zeros(shape, dtype=self.dtype)
else:
with self.lock:
riods = _ensure_warped_vrt(
with _ensure_warped_vrt(
self.manager.acquire(needs_lock=False), self.vrt_params
)
out = riods.read(band_key, window=window, masked=self.masked)
if self._unsigned_dtype is not None:
out = out.astype(self._unsigned_dtype)
if self.masked:
out = numpy.ma.filled(out.astype(self.dtype), self.fill_value)
if self.mask_and_scale:
if not isinstance(band_key, Iterable):
out = (
out * riods.scales[band_key - 1]
+ riods.offsets[band_key - 1]
)
else:
for iii, band_iii in enumerate(numpy.atleast_1d(band_key) - 1):
out[iii] = (
out[iii] * riods.scales[band_iii]
+ riods.offsets[band_iii]
) as riods:
out = riods.read(band_key, window=window, masked=self.masked)
if self._unsigned_dtype is not None:
out = out.astype(self._unsigned_dtype)
if self.masked:
out = numpy.ma.filled(out.astype(self.dtype), self.fill_value)
if self.mask_and_scale:
if not isinstance(band_key, Iterable):
out = (
out * riods.scales[band_key - 1]
+ riods.offsets[band_key - 1]
)
else:
for iii, band_iii in enumerate(
numpy.atleast_1d(band_key) - 1
):
out[iii] = (
out[iii] * riods.scales[band_iii]
+ riods.offsets[band_iii]
)

if squeeze_axis:
out = numpy.squeeze(out, axis=squeeze_axis)
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ classifiers =
Operating System :: OS Independent
Topic :: Scientific/Engineering :: GIS
Programming Language :: Python
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3
Topic :: Software Development :: Libraries :: Python Modules
Typing :: Typed
Expand All @@ -30,7 +30,7 @@ download_url = http://python.org/pypi/rioxarray
packages = find:
zip_safe = False # https://mypy.readthedocs.io/en/stable/installed_packages.html
include_package_data = True
python_requires = >=3.9
python_requires = >=3.10
install_requires =
packaging
rasterio>=1.2
Expand Down

0 comments on commit 047851d

Please sign in to comment.