-
Notifications
You must be signed in to change notification settings - Fork 12
Add matrix, array and matrix multiplication for integer64 #195
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
Conversation
refactor str.integer64 for consistent display of matrices refactor colSums and rowSums to be consistent to base
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
try fix tests for ubuntu latest
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
MichaelChirico
left a comment
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.
I think it's basically ready. Thanks!
|
Thank you for the review! |
| } else { | ||
| array(as.integer64(x), c(length(x), 1L), {if (!is.null(names(x))) list(names(x), NULL) else NULL}) | ||
| } | ||
| array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), NULL)) |
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.
I added this as.integer64, because I think it is good practice to assure that this method returns integer64, even though it might have been called directly internally without integer64.
But here the result would be inconsistent within the method, because if the input would be a non-integer64 matrix, it would be returned without converting to integer64.
Should I modify it to assure an integer64 return value or leave it as it is?
@MichaelChirico ?
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.
Generally I think it's overkill to call as.* again from within a .* S3 method -- if we get non-integer64 input, user is playing with fire :)
We have a few ugly checks in as.data.table.data.frame that are basically there for back-compatibility -- I'd rather the user be stuck debugging such cases:
This pull request adds support for
matrix,arrayand%*%forinteger64. Since there are no S3 methods formatrixandarray, they are added.In
matrixandarraythe base functions are used. In order to display convinient warnings and errors that show the call (e.g.matrix(1:10, nrow=5)instead ofbase::matrix(...)) I usewithCallingHandlers(). If there is a generic call, this is displayed, and if not, the S3-method call is displayed.In order to display matrices and arrays consistently to R,
str.integer64is changed accordingly.colSums.integer64androwSums.integer64are refactored to throw R consistent error messages.as.matrix.integer64is added to coerce accordingly.Since
aperm.integer64isn't exported, one has to use the generic. Thus it is refactored to useNextMethod().The matrix multiplication uses a new helper function
target_class_for_Ops(), which determines the class of the result. If a matrix multiplication ofinteger64andcomplexis performed, I expect the result incomplex. It also throws R consistent error messages for Ops. This helper is also intended to be used for other Ops methods like*.integer64in the future. The remaining method checks the matrix dimensions and performs the calculation.Closes #45