Rename rasterize() use_cuda to gpu with a deprecation shim (#3089)#3122
Merged
brendancol merged 3 commits intoJun 10, 2026
Conversation
gpu= matches open_geotiff() and the accessor. use_cuda stays as a keyword alias: it warns with DeprecationWarning and maps onto gpu; passing both raises TypeError. The new gpu param sits in use_cuda's old position so positional callers are unaffected. polygon_clip's internal dask+cupy call and the rasterize test suite now use gpu=.
brendancol
commented
Jun 9, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
PR Review: Rename rasterize() use_cuda to gpu with a deprecation shim (#3089)
Blockers (must fix before merge)
- None.
Suggestions (should fix, not blocking)
-
benchmarks/benchmarks/rasterize.py(lines 100-125, 145) still callsrasterize(..., use_cuda=...). The benchmarks will emit a DeprecationWarning on every run and keep the old spelling alive in repo code. Migrate them togpu=in this PR since the rename is the whole point.
Nits (optional improvements)
-
xrspatial/rasterize.py:3300uses.. deprecated:: 0.11, but the repo is at 0.10.7.dev with a 1.0.0 milestone open, so the named version may never exist. Either use the actual next release or drop the version number and say it in prose.
What looks good
- The new
gpuparameter occupiesuse_cuda's old slot, so positional callers are untouched; the alias is appended last. The slot is pinned by a test. - Shim semantics are the same as the focal/zonal renames: warn on the alias, TypeError when both are passed,
stacklevel=2. polygon_clip.pyguards against the case where a caller passesuse_cudathroughrasterize_kw; without the guard the internalgpudefault would collide with it and raise.- Test migration was checked for sed damage (
_xs_mask,_runhelpers read correctly; no strayuse_cudanames remain in tests). - All four entry points (numpy, cupy, dask+numpy, dask+cupy) verified on a CUDA host with identical kwargs and matching values; 649 rasterize tests plus 23 polygon_clip tests pass.
Checklist
- Algorithm matches reference (n/a -- API rename, no numerics touched)
- All implemented backends produce consistent results
- NaN handling is correct (untouched)
- Edge cases covered (both-args TypeError, alias=False, no-warning default)
- Dask chunk boundaries handled correctly (untouched)
- No premature materialization or unnecessary copies
- Benchmark exists but still uses the deprecated kwarg (see suggestion)
- README feature matrix: no change needed
- Docstrings present and accurate (modulo the version nit)
brendancol
commented
Jun 9, 2026
brendancol
left a comment
Contributor
Author
There was a problem hiding this comment.
Follow-up review after 1104382:
- Benchmarks suggestion: fixed. All six benchmark classes in
benchmarks/benchmarks/rasterize.pynow setself.gpuand callrasterize(..., gpu=...); nouse_cudaremains outside the shim itself and its regression tests. - Version nit: fixed. The alias docstring entry now states the deprecation in prose instead of naming a release that may never exist.
Re-checked the shim, tests (11 passed across the alias and annotation suites), and lint on the touched files. The two flake8 F401s in the benchmark file predate this PR. No new findings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3089
rasterize()was the only public function spelling the GPU opt-inuse_cuda;open_geotiff()and the accessor usegpu. Both names were live in the public API for the identical concept, so anyone moving between the two functions hit a TypeError.gpu. It keepsuse_cuda's position in the signature, so positional callers see no change.use_cudastays as a keyword alias appended at the end: it emits aDeprecationWarningpointing atgpu=and maps onto it. Passing both raisesTypeError.polygon_clip.py's internal dask+cupy call now usegpu. The polygon_clip path is guarded so a legacyuse_cudapassed viarasterize_kwkeeps working instead of colliding with the new default.gpu=.Backend coverage: numpy, cupy, dask+numpy, and dask+cupy entry points all verified on a CUDA host; values match across backends with identical kwargs.
Test plan (new file
test_rasterize_gpu_alias_3089.py):gpuoccupies the olduse_cudaslot; alias is the last parameteruse_cuda=True/Falsewarns and behaves likegpu=gpu=True+use_cuda=...raises TypeErrorclip_polygonon a dask+cupy raster emits no DeprecationWarning