Conversation
shape_availability checked the truthiness of codes, so the integer 0 was handled like a missing codes argument: all non-zero cells were excluded instead of the cells with value 0. A numpy array raised a ValueError for the same reason. Check for None instead.
This branch has not been deployed
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.
Changes proposed in this Pull Request
ExclusionContainer.add_raster(raster, codes=0)currently excludes every non-zero cell instead of the cells with value 0, becauseshape_availabilitychecks the truthiness ofcodesand the integer 0 is handled like a missing argument. The same check breaks numpy arrays:np.array([0])gives the inverted mask and a longer array raises aValueError. I changed the check tois not None, so 0 and arrays now behave like the list formcodes=[0]. One side effect to point out: an empty list used to fall back to "exclude all non-zero cells" and now excludes nothing. I also corrected the docstring, which said the default is 1 while it isNone. The new test intest/test_gis.pyneeds no download and fails on master.Checklist
doc.environment.yaml,environment_docs.yamlandsetup.py(if applicable).doc/release_notes.rstof the upcoming release is included.