Fix deprecated affine parameters#299
Conversation
|
Please review this |
|
Hello @Chandraveersingh1717, Thanks for this proposal. I'll be happy to review it then. |
5da4c8b to
1a2d3c6
Compare
b793f64 to
286ee7d
Compare
| transform_random_rotation <- function(img, degrees, interpolation = 0, expand=FALSE, | ||
| center=NULL, fill=NULL, resample) { | ||
| if (!missing(resample)) { | ||
| warning("'resample' is deprecated, use 'interpolation' instead") |
There was a problem hiding this comment.
todo please do not use warning() but rather one of the functions in conditions.R such as deprecated() in order for package translation to work.
There was a problem hiding this comment.
todo generated artifact Please remove commented line of equal sign
question why did you reduce the function documentation down to something limited to informed users ?
suggestion blocking please revert the function parameter documentation
todo You cannot remove exemples in function documentation. Please revert
| warn_msgs <- character(0) | ||
| old <- withCallingHandlers( | ||
| transform_affine(x, 0, c(0, 1), 1, 0, resample = 0, fillcolor = 0), | ||
| warning = function(w) { | ||
| warn_msgs <<- c(warn_msgs, conditionMessage(w)) | ||
| invokeRestart("muffleWarning") | ||
| } | ||
| ) | ||
|
|
||
| new <- transform_affine(x, 0, c(0, 1), 1, 0, interpolation = 0, fill = 0) | ||
|
|
||
| expect_equal(sum(grepl("resample", warn_msgs)), 1) | ||
| expect_equal(sum(grepl("fillcolor", warn_msgs)), 1) | ||
| expect_equal_to_r(old, as_array(new)) |
There was a problem hiding this comment.
todo readability & consistency please rely on the much simpler expect_warning() is you expect a warning from a function call.
|
Thanks for the updates! I’ve checked the changes and have a much clearer idea of the expected direction now. I’ll make sure to align my future changes with this. |
Replace deprecated parameter names in transform functions
The transform functions were using
resampleandfillcolorparameters, which are deprecated in PyTorch's API. This updates them to useinterpolationandfillinstead to match the current PyTorch conventions.What changed
resampletointerpolationin rotate and affine transformsfillcolortofillin affine transformsFunctions updated
Backward compatibility
Old parameter names still work but show a warning message:
transform_rotate(img, angle = 45, resample = 0) # works, shows warning
transform_rotate(img, angle = 45, interpolation = 0) # recommended