Repository navigation
shift no longer works on matrix type under 1.14.3 #5287
Description
Activity
- changed the title
[-]1.14.3 `shift` no longer works on matrix type[/-][+]`shift` no longer works on matrix type under 1.14.3[/+]on Dec 12, 2021 Introduced in #5189. It's erroring because
coerceAscannot handle matrix/arrays.
Same error ofc also appears fornafill(matrix(c(NA, 1:9), ncol = 1), fill=0)which also happened to "work" before #4491.According to docs
shift/nafillnever supportedmatrixbut happened to work because matrices/array are R internally represented via one-dimensonial arrays with attributes.@jangorecki are there reasons why
coerceAs(x, as, copy)doesn't allow matrices/arrays for argumentsxandas?There reason is that there was no such requirement when it was implemented.
https://rdatatable.gitlab.io/data.table/library/data.table/html/shift.html does not mention matrix, but "A vector, list, data.frame or data.table" only, as Ben pointed out.the fix in this case is very simple:
data.table::shift(c(matrix(1:10, ncol = 1)))The earlier behavior on multi-column matrices is IMO quite undesirable, so I'm happy to break it in this case. Though we could improve the error message by catching it earlier.
- for the record, im not asking for the old functionality to be restored. was more pointing out that it did break existing code, so probably warrants a section in the news if intentional (which it looks like it is)…________________________________ From: Michael Chirico ***@***.***> Sent: Saturday, December 18, 2021 11:35 PM To: Rdatatable/data.table ***@***.***> Cc: Ethan Smith ***@***.***>; Author ***@***.***> Subject: Re: [Rdatatable/data.table] `shift` no longer works on matrix type under 1.14.3 (Issue #5287) the fix in this case is very simple: data.table::shift(c(matrix(1:10, ncol = 1))) The earlier behavior on multi-column matrices is IMO quite undesirable, so I'm happy to break it in this case. Though we could improve the error message by catching it earlier. — Reply to this email directly, view it on GitHub<#5287 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AF2ACB3WRSFSLTBRJJ7TWLTURV4LXANCNFSM5J4UTY6Q>. Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>. You are receiving this because you authored the thread.Message ID: ***@***.***>
Though we could improve the error message by catching it earlier.
Was about to do it, but realized I will just copy error message from
coerceAsintonafillandshift. IMO it's better to catch it there, in single a place.
shiftused to work on matrix columns, but now generates and error. i dont see anything in the NEWS. is this intentional as its a breaking change?works in 1.14.0
not working under 1.14.3