bump: validate agg, count, and spread inputs#3614
Open
brendancol wants to merge 1 commit into
Open
Conversation
bump() only validated width and height. Bad values for the agg template, count, and spread surfaced numpy/dispatcher errors from deep in the call or were silently accepted: - agg as a plain ndarray -> 'Unsupported Array Type' from the backend dispatcher; a 3D/1D DataArray -> 'too many values to unpack' from the bare h, w = agg.shape unpack. Neither named agg. - count negative/float -> raw np.empty errors. - spread negative/float -> accepted silently, dropping the spreading the caller asked for despite the docstring saying int. Add _validate_raster(agg, ndim=2, numeric=False) and _validate_scalar for count (>=0) and spread (>=0), matching the existing width/height checks. bump only reads agg's shape/backend so dtype stays unchecked. spread=0 and count=0 remain valid. Verified across numpy, cupy, dask, and dask+cupy. error-handling sweep 2026-07-02
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.
What
bump()validated onlywidthandheight. This adds the same style of validation toagg,count, andspread, using the existing_validate_rasterand_validate_scalarhelpers.Before, bad inputs surfaced errors from deep in the call or passed silently:
agg=np.zeros((10,10))TypeError: Unsupported Array Typefrom the backend dispatcheragg3D/1D DataArrayValueError: too many values to unpackfromh, w = agg.shapecount=-5/count=5.0np.emptyerrorsspread=-3/spread=2.5After, each raises a message that names the parameter, e.g.
bump(): \agg` must be 2D, got 3D`.Notes
bumponly readsagg's shape and backend, so I left the dtype unchecked (numeric=False).spread=0andcount=0stay valid.spreadchanges behavior for inputs that were previously accepted silently. Those values are out of domain per the docstring (spread : int), and no test relied on them.Tests
Added error-path tests asserting the new exception type and message for each case, plus a check that
spread=0still works. Fulltest_bump.pypasses (23 tests) on numpy, cupy, dask, and dask+cupy.error-handling sweep, 2026-07-02