TypeError when passing a list of values to .index
since version 1.4.1
#3385
-
Expected behavior and actual behavior.I'm currently updating some dependencies for a library (github.com/shuttle1987/pyidw) and I have run into the following issue with existing code breaking when updating the version of rasterio. (The regression I'm trying to fix can be found here: github.com/shuttle1987/pyidw/issues/1) Steps to reproduce the problem.In the existing code lists of values were passed to with rasterio.open(resized_raster_name) as baseRasterFile:
inputPoints = gpd.read_file(input_point_shapefile)
# obser_df stands for observation_dataframe, lat, lon, data_value for each station will be stored here.
obser_df = pd.DataFrame()
obser_df['station_name'] = inputPoints.iloc[:, 0]
# create two list of indexes of station longitude, latitude in elevation raster file.
lons, lats = baseRasterFile.index(
[lon for lon in inputPoints.geometry.x],
[lat for lat in inputPoints.geometry.y]) This used to work but now creates a type error:
I can see that the breakage in the source code above was caused by the changes in this commit: Where this line: return rowcol(transform, x, y, zs=z, op=op, **rpc_options) was changed to this: return tuple(int(val) for val in rowcol(transform, x, y, zs=z, op=op, **rpc_options)) Given the bump in the patch version it was somewhat surprising that backwards compatibility was broken. Now I could pin rasterio to an older version before this change was made but I'd much rather stay up to date with rasterio packages, what should I modify in my existing code here to keep up to date with the changes in the upstream library? Environment Information
Installation MethodI installed rasterio via the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment · 1 reply
-
@shuttle1987 |
Beta Was this translation helpful? Give feedback.
@shuttle1987
.index()
accidentally accepted sequences of x and y input before, but it was never intended. The documentation made it pretty clear, I think, that the function was intended to work on scalars. We've removed the unintended and undefined behavior. I call that a bug fix.