Researched and drafted by Claude (Anthropic's AI model, in Claude Code), which also ran the measurements below; reviewed by @bjlittle before posting.
Type checking geovista against types-rasterio 1.5.2.20261005 turned up three places where the rasterio stubs are narrower than rasterio 1.5.2 at runtime.
-
rasterio.transform.xy types rows and cols as int | Sequence[int], and its result as tuple[float, float] | tuple[list[float], list[float]]. rasterio takes numpy arrays, and gives arrays back for them:
import numpy as np
from rasterio.transform import from_origin, xy
transform = from_origin(10.0, 20.0, 1.0, 1.0)
rows, cols = np.meshgrid(np.arange(2), np.arange(3), indexing="ij")
xs, ys = xy(transform, rows.flatten(), cols.flatten())
type(xs) # <class 'numpy.ndarray'>
An ndarray is not a Sequence, so a caller passing one needs a cast.
-
DatasetBase.crs is typed CRS, but a GeoTIFF without a CRS gives None.
-
DatasetReaderBase.read is typed to return NDArray[Any] whatever masked is, but with masked=True it returns a numpy.ma.MaskedArray, so using its mask doesn't type check.
If any of these would be welcome as a pull request, Claude can prepare one the same way, for @bjlittle to review before it is opened.
🤖 Generated with Claude Code
Type checking geovista against
types-rasterio1.5.2.20261005 turned up three places where therasteriostubs are narrower thanrasterio1.5.2 at runtime.rasterio.transform.xytypesrowsandcolsasint | Sequence[int], and its result astuple[float, float] | tuple[list[float], list[float]].rasteriotakes numpy arrays, and gives arrays back for them:An
ndarrayis not aSequence, so a caller passing one needs a cast.DatasetBase.crsis typedCRS, but a GeoTIFF without a CRS givesNone.DatasetReaderBase.readis typed to returnNDArray[Any]whatevermaskedis, but withmasked=Trueit returns anumpy.ma.MaskedArray, so using itsmaskdoesn't type check.If any of these would be welcome as a pull request, Claude can prepare one the same way, for @bjlittle to review before it is opened.
🤖 Generated with Claude Code