-
Notifications
You must be signed in to change notification settings - Fork 8
Lower array(data=<non-scalar>, dim=...) via reshape() #93
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66ef931
Support array() reshaping non-scalar data
t-kalinowski b6e46aa
Relax array(dim=) checks for reshape
t-kalinowski a8772b2
Fix array() reshape source and dim handling
t-kalinowski 1b63a44
Handle dim=2:4 and avoid splitting Fortran dim strings
t-kalinowski d70138f
Fix array() dim=1 scalarization for non-scalar data
t-kalinowski 053a60e
Fix array() hoist forwarding
t-kalinowski d2bc501
Reject empty array(dim=)
t-kalinowski f60c0b8
array(): fail fast when reshape would require recycling
t-kalinowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| test_that("array() supports reshaping non-scalar data", { | ||
| fn <- function(x) { | ||
| declare(type(x = integer(2L, 3L, 4L))) | ||
| array(as.double(x), dim = c(2L, 3L, 4L)) | ||
| } | ||
|
|
||
| set.seed(1) | ||
| x <- array(sample(1:10, 24, replace = TRUE), dim = c(2L, 3L, 4L)) | ||
| expect_quick_identical(fn, list(x)) | ||
| }) |
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
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.
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.
The new validation rejects any
dimthat isn't an integer vector with rank 1, but base R allows numeric (double) dims and also allows a scalardim(length‑1) which is coerced to an integer vector. This means common calls likearray(as.double(x), dim = c(2, 3))orarray(as.double(x), dim = 2)will now error at compile time even thoughint()would coerce successfully. Consider relaxing the check to accept numeric/scalar dims and coercing to integer rather than stopping.Useful? React with 👍 / 👎.