-
Notifications
You must be signed in to change notification settings - Fork 20
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
Modify set_nodata
behaviour, improve related warnings and tests
#309
Conversation
It's great to have everything a bit more consistent now ! Thanks ! 👏
A good way to increase your git blame score 😝
See my comment, I would simply raise an error and tell the user to use set_nodata, as it will force the use to think about the consequences. |
Actually, I already checked, and there's not a single function using this in xDEM! 🥳 Except what I just added to remove the floating nodata in the |
But I'm quite happy! The change in the function themselves is not so impressive, but our test suite has gained nearly 1000 lines to ensure all is robust! And there were a lot of weird behaviours before those were corrected with the new tests! 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, except for a minor comment to one test
This PR homogenizes the getter and setter functionality related to
nodata
and adds more exhaustive tests.In details, this PR:
set_ndv()
intoset_nodata()
, and all other occurences of "ndv" to "nodata", in order to match thenodata
naming ofrasterio
and avoid the confusion of having "ndv" and "nodata" standing for the same thing,update_array
inset_nodata()
,update_mask
argument toset_nodata()
,nodata.setter
method that callsset_nodata()
with default parameters,set_nodata
andnodata.setter
,The old behaviour was:
update_array
wasFalse
by default,update_array
would modify.data.mask
by unmasking old nodata and masking new nodatas (i.e. a rare case where the nodata value was wrongly defined and needed to be changed while ignoring old nodatas).The new behaviour is:
update_array
andupdate_mask
areTrue
by default,update_array
updates the array.data.data
by replacing old nodata values into new nodata values.update_mask
updates the mask.data.mask
by unmasking old nodata and masking new nodatas (including the ones possibly updated byupdate_array
, i.e. essentially keeping the mask on old nodata that have been updated, which makes the big difference with the previous behaviour).UserWarning
is raised if the new nodata value already exist as a valid value of the array (as it will be automatically masked).This behaviour is also explained in the function description, with typical use-cases.
Resolves #286