-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Range indexing: error with scalar bool index like all other arrays #31829
Conversation
Is there a green light to make this fix (if yes I will rebase and add tests to finalize the PR). |
I can go back and update this PR if there is a green light to implement changes sanitizing |
The goal here seems good to me. It initially felt like we should be able to do better in the implementation by punting to |
Co-authored-by: Matt Bauman <[email protected]>
OK - I will rebase then and finalize the PR |
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.
Still some ambiguities hiding here, too — that'll be the biggest painpoint for custom packages that subtype AbstractRange
, but fortunately the ambiguities should themselves be errors (it's just not quite the error we want).
Co-authored-by: Matt Bauman <[email protected]>
Right, I am too much used to DataFrames.jl development recently where we are mostly in full control. Maybe then it is better not to add any new methods but use
this |
@mbauman - could you please comment if you think that doing checking within the original method as I proposed above would be preferred (it for sure will reduce the risk of ambiguities). I will update the PR following your recommendation and make the tests pass. Thank you! |
bump (as otherwise probably everyone will forget about the details of the design and it is non-obvious in some places) |
Bump again - is it OK to merge? Sorry for pushing - I know this PR has a non-obvious logic in several places, but I have a long list of PRs to JuliaLang/julia that are unfinished because I did not push for a decision on them. |
The error in https://build.julialang.org/#/builders/1/builds/22/steps/5/logs/stdio seems unrelated, but maybe I do not see something important that causes this error in this PR. |
I keep forgetting this, sorry. Let's re-run CI since it looks a little stale and then get it in. |
The CI failure on package_win32 seems unrelated (but I am not super experienced with reading them as I have not contributed to Julia Base for a while). |
bump |
1 similar comment
bump |
CI failure is #39667. |
As reported in JuliaData/DataFrames.jl#2648 this change catches the decision to be made with
In DataFrames.jl I decided to recommend disallowing passing |
@timholy Do you agree that this should error:
(as it does now - I am pinging you as you have designed |
Follow up to the problem discussed in JuliaLang#31829 (comment). I came to the conclusion that `CartesianIndices((true,))` should be allowed as in this context `true` represents a dimension length not an index.
if first(s) | ||
return r | ||
else | ||
return range(r[1], length=0) |
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.
return range(r[1], length=0) | |
return range(first(r), length=0) |
In case someone makes an OffsetUnitRange?
return range(first(r), step=one(eltype(r)), length=0) | ||
end | ||
else # length(s) == 2 | ||
return range(r[2], step=one(eltype(r)), length=1) |
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.
return range(r[2], step=one(eltype(r)), length=1) | |
step = one(eltype(r)) | |
return range(first(r) + step; step, length=1) |
Follow up to the problem discussed in #31829 (comment). I came to the conclusion that `CartesianIndices((true,))` should be allowed as in this context `true` represents a dimension length not an index.
Follow up to the problem discussed in JuliaLang#31829 (comment). I came to the conclusion that `CartesianIndices((true,))` should be allowed as in this context `true` represents a dimension length not an index.
Follow up to the problem discussed in JuliaLang#31829 (comment). I came to the conclusion that `CartesianIndices((true,))` should be allowed as in this context `true` represents a dimension length not an index.
This is an initial proposal fixing #31726. It is a bit messy as @mbauman indicated there.
If we are OK with the proposed approach I will write tests for this PR.