Improve corner cases of deleteat!#42144
Conversation
|
What problems this PR tries to solve: |
|
I will add tests and NEWS.md entry if the proposed changes would be acceptable. |
base/bitarray.jl
Outdated
| if length(B) != length(inds) | ||
| throw(ArgumentError("length of Bool indices inds must match the length of B")) | ||
| end | ||
| return deleteat!(B, findall(inds)) |
There was a problem hiding this comment.
clearly this can be made faster, but will lead to some code duplication. Should I improve things here?
There was a problem hiding this comment.
Seems fine for now. Would it be faster to reuse the code for Vector (at least avoiding the allocation)? The Vector method should work if _deleteend! is just replaced with resize!.
There was a problem hiding this comment.
no - it would not be fully efficient. I will implement an efficient method and you will judge.
dkarrasch
left a comment
There was a problem hiding this comment.
Just stumbled across the typo.
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
|
I have not made PRs to Julia for some time. Could someone please guide me through which CI jobs are running the actual tests of the functionality? (as there seem to be many jobs doing some specific testing) Thank you! |
AFAIK "package" jobs only build Julia, "tester" jobs run the tests. Not sure about others. |
|
Looks great, just need to fix the tests. |
|
|
||
| (p, s) = y | ||
| checkbounds(B, p) | ||
| p isa Bool && throw(ArgumentError("invalid index $p of type Bool")) |
There was a problem hiding this comment.
We can throw an error here (and not just warn about deprecation), because earlier it already threw an error as a side effect of lack of conversion of p to Int where needed later. (same below)
The current behavior is:
julia> deleteat!(falses(5), Any[true])
ERROR: MethodError: no method matching copy_chunks!(::Vector{UInt64}, ::Bool, ::Vector{UInt64}, ::Int64, ::Int64)
julia> deleteat!(falses(5), Any[1, true])
ERROR: ArgumentError: indices must be unique and sorted
Now in both cases we will throw throw(ArgumentError("invalid index $p of type Bool"))
| end | ||
|
|
||
| function splice!(B::BitVector, i::Integer) | ||
| # TODO: after deprecation remove the four lines below |
There was a problem hiding this comment.
I have also added the checks for Bool to splice! as they are done in non-BitVector case:
julia> splice!([1,2,3], true)
ERROR: ArgumentError: invalid index: true of type Bool
julia> splice!([1,2,3], true, [4,5])
ERROR: ArgumentError: invalid index: true of type Bool
I have fixed. Actually the test was correct, but it was failing because there was an additional issue with lacking conversion to |
|
re-triggering CI |
|
A single CI error seems unrelated, so this should be good for a final review. |
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de> (cherry picked from commit deb3fac)
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
|
Could this PR be backported to 1.6 release? see JuliaData/DataFrames.jl#3300 |
This addresses issues discussed in #42065 (comment) for
deleteat!.