Skip to content

BUG: Use @ for Affine matrix multiplication - #942

Open
raashish1601 wants to merge 1 commit into
corteva:masterfrom
raashish1601:fix/937-affine-matmul
Open

raashish1601 wants to merge 1 commit into
corteva:masterfrom
raashish1601:fix/937-affine-matmul

Conversation

@raashish1601

Copy link
Copy Markdown

affine 3 deprecates * for matrix multiplication, so open_rasterio and rio.transform(recalc=True) emit a PendingDeprecationWarning. This switches those calls to @. #939 did this before it was closed by its author; I followed the review there: only the matrix multiplication change, plus the rasterio>=1.5.1 and affine>=3 floors.

Other changes needed for affine 3:

  • Affine is no longer a tuple, so assert_almost_equal on two transforms fails with "truth value of an array is ambiguous". This is what fails the 42 integration tests on master CI right now. Those asserts now compare tuple(transform).
  • affine 3 ships type hints that don't cover arrays of coordinates, so mypy flags affine_to_coords (it also does on master with *). The centered transform is annotated as Any there.

New tests in test/unit/test_spatial_utils.py turn PendingDeprecationWarning into an error and cover affine_to_coords (rectilinear and rotated) and rio.transform(recalc=True). They fail on master and pass here.

Tested in a Linux container with rasterio 1.5.2 and affine 3.0.1: the full suite goes from 59 to 17 failures. The 17 left fail the same way on master in that environment (no HDF4 driver in the rasterio wheel, and checksum differences in test_clip_geojson__no_drop). pre-commit, mypy and pylint pass.

@raashish1601

Copy link
Copy Markdown
Author

The AppVeyor job hit its 60 minute limit while conda was still solving the environment (the log stops at "Collecting package metadata"), so no tests ran there. It isn't from this change; a rerun should get past it.

@snowman2 snowman2 added the bug Something isn't working label Oct 10, 2026
@snowman2 snowman2 added this to the 0.23.1 milestone Oct 10, 2026
@raashish1601

Copy link
Copy Markdown
Author

The ubuntu 3.12 job fails in the pylint step on W0613 (unused kwargs) in rioxarray/_convention/zarr.py and cf.py, which this PR doesn't touch. pylint 4.1.2 reports the same on master. I can fix that in a separate PR if you like.

@snowman2

Copy link
Copy Markdown
Member

I can fix that in a separate PR if you like.

That would be helpful.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rioxarray.open_rasterio starting to emit warning from affine

2 participants