-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide better error handling for NA/NaN keys in value map in reclassify raster function #419
Comments
The difference in error messages for the numpy.isclose function arises from using different NumPy versions. Earlier versions of InVEST (and Workbench) used NumPy 1.24, which produced the latter error when calling numpy.isclose(pandas.NA, 255.0). In contrast, the current version of InVEST uses NumPy 2.1, which generates the former error when comparing pandas.NA to a float. |
Are we (and should we be) using the |
Using Regardless of how For more context: The function is using |
I think this is the key question. For I do think it's possible for a raster to have I don't think it's necessary to support |
I'm not exactly sure where this comes up, and I think it's kind of a separate issue from the non-numeric cases ( |
Or not, if the function is not intended to operate on floats. |
Ok so the proposed solution as of now is to check for non-numeric keys in the |
Check for non-numeric keys in value_map in reclassify raster function #419
Currently reclassify_raster will fail if there is a NA key in the value map. This is because we are using np.isclose to check if any of the value_map keys are close to the nodata value, and isclose cannot handle NA values.
The current error message produced will be either TypeError: boolean value of NA is ambiguous (if trying to check pandas.NA against another value, as occurs when value map is created from a csv with an empty row value), or TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' (if comparing a value (including NA) to NA; possibly in other situations).
The text was updated successfully, but these errors were encountered: