-
Notifications
You must be signed in to change notification settings - Fork 11
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
add deleteat! method #56
base: main
Are you sure you want to change the base?
Conversation
@vlepori looking at this again, maybe the primary way to do it should be ElasticArrays.jl/src/elasticarray.jl Line 108 in 7e0b6f8
Could you change ElasticArrays.jl/src/elasticarray.jl Line 106 in 7e0b6f8
? |
Oh, and could you add a test or two? |
Good point, both APIs are supported now. I also added a couple of tests. |
test/elasticarray.jl
Outdated
@@ -296,6 +296,26 @@ using Random, LinearAlgebra | |||
end | |||
|
|||
|
|||
@testset "deleteat!" begin | |||
|
|||
function deleteat_test() |
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.
Why wrap this in a function?
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.
Just consistency, since other functions are tested with a functionname_test()
. But we can also call test_E()
directly
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.
But we can also call test_E() directly
Let's to that, it's simpler. I mainly wrapped tests if there are called several times with different arrays sizes or so.
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.
Yeah that makes sense, I simplified it.
test/elasticarray.jl
Outdated
@test_throws ArgumentError deleteat!(E, ntuple(_ -> 1, ndims(E))) | ||
@test_throws MethodError deleteat!(E, ntuple(_ -> (), ndims(E) - 1)) | ||
@test_throws BoundsError deleteat!(E, ntuple(i -> i == n ? s + 1 : (), n)) | ||
@test E == deleteat!(E, ntuple(_ -> (), n)) |
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.
Can you add an @inferred
here?
test/elasticarray.jl
Outdated
@test_throws MethodError deleteat!(E, ntuple(_ -> (), ndims(E) - 1)) | ||
@test_throws BoundsError deleteat!(E, ntuple(i -> i == n ? s + 1 : (), n)) | ||
@test E == deleteat!(E, ntuple(_ -> (), n)) | ||
@test selectdim(E, n, 2:s) == deleteat!(b, ntuple(i -> i == n ? 1 : (), n)) |
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.
An @inferred
might be nice here as well.
Ok, let's run Ci on it then. :-) |
Codecov Report
@@ Coverage Diff @@
## main #56 +/- ##
==========================================
- Coverage 84.74% 84.49% -0.25%
==========================================
Files 2 3 +1
Lines 118 129 +11
==========================================
+ Hits 100 109 +9
- Misses 18 20 +2
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hm, looks like there trouble on v1.0 . |
At least one problem here is that the method |
Yes, I think that should be Ok. |
Hey @vlepori I'm so sorry this got stalled, I completely forgot to click "run CI" ... |
@vlepori could you take a look at the failing tests? |
@oschulz yes sorry, I'll try to get a working installation of Julia 1.0 and look into this soon ! |
Thanks @vlepori , no worries! |
Would love to see this added, could be great to use it to implement |
@vlepori want to get back on this? |
Sure! Got sidetracked and forgot about this but if there is interest I will try to get it done! |
So I went down the rabbit hole behind this failing test on julia 1.0 ElasticArrays.jl/test/elasticarray.jl Line 310 in 34d0809
It seems to have nothing to do with ElasticArrays but seems related to a weird side effect of the using Test
function fun()
d = 2
@test true # works as aspected when commenting out this line
ntuple(i -> i == d ? true : false, 2)
end
fun() # should return (false,true) but gives (true,true) I don't quite understand further (?) but the bug has been fixed in more recent versions, so maybe just skip the test ? |
Hm, now that v1.10 is set to become the new LTS, maybe it's time to drop v1.0 support? |
Not sure if it's necessary for just this one test, but I'd be surprised if many people still use 1.0. For comparison |
Looks like among the package that depend on ElasticArrays, the packages EfficientGlobalOptimization, StanSample and SphericalHarmonics still (claim to ) support Julia v1.0. So I suggest we do indeed skip the test, but keep v1.0 compatibility for now. |
As discussed in #55. I kept the
deleteat!(A,(),i)
API.The following are supported
And this errors